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; } } } ==================================================
"P1_1 is always 1 thus the test in ictalics is irrelevant"
But with P0.0 and P0.1 using weak pull-up, external switches can draw one or both of P0.0 and P0.1 low allowing the user to test the full set of logic combinations of P0.0 and P0.1.
The big problem with the test program is that the "count" variable will constantly flip between test case 0 and test case 1, which means that the program will at very high speed switch between the first and the second logic table, resulting in the output LED in some situations be fully on, sometimes fully off, and sometimes be lit with 50% duty cycle resulting in a lower intensity.