8051 programming help

Thread Starter

tharunmalli

Joined Apr 7, 2014
12
I need to write a c program to receive a character from hyperterminal . If the entered character is y then P0^1 should go high and if i press n then P0^0 should go low, if i press any other character it should retain its previous state..
please help me..
 

Thread Starter

tharunmalli

Joined Apr 7, 2014
12
I compiled the below program . It is showing error near P0^0=1 .. Please find the mistake and post the correct code. Please help
#include<reg51.h>
unsigned char mybit;
void main(void)
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0);
mybit=SBUF;
if(mybit=='y')
P0^0=1;
if(mybit=='n')
P0^1=0;
RI=0;
}
}
 

Arm_n_Legs

Joined Mar 7, 2007
186
Maybe the usage of P0^0 is wrong.

Try this:
After the include statement, define P0.0 and P0.1 as follows:
sbit P00 = P0^0;
sbit P01 = P0^1;

To set P0.0 to 0; use P00=0;
 
Top