This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How input output works in MC

Hi , I am very new to MC coding , and I am trying to simulate an ouput based on this table

IP1 IP2    OP
(first time)
0       0       =       1
0       1       =       1               //changing
1       1       =       0
1       0       =       0

(second time)
0       0       =       1
0       1       =       0               //changing
1       1       =       0
1       0       =       0


*** I want to read , two inputs and and I have to display the outuput ***

1.Whether I am getting the input correct as P1_0 and P1_1 , and displaying output P2_0
2. what is P1^1 ? (i got the sample code from internet and edited it , I know C program well)

I have written this code , please anybody validate and tell me , what I am missing here

=======================================================
#include <REG51.H>

sbit P1_0 = P1^0;     /* SFR for P1.0 */
sbit P1_1 = P1^1;     /* SFR for P1.1 */

sbit P2_0 = P2^0;     /* SFR for P2.0 */

unsigned int count=0;

void main (void)
{
        P1_0 = 1;
        P1_1 = 1;
        while (1)
  {
                if(count==0)
                {
                        if(P1_0 ==0) {
                                P2_0=1;
                        }
                        else {
                                P2_0=0;
                        }
                        count=1;
                }
                else
                {
                        if(P1_0==0 && P1_1==0) {
                                P2_0=0;
                        }
                        else {
                                P2_0=1;
                        }
                        count=0;
                }
  }
}
==================================================