fatima_just
Junior Member level 1
sbuf in 8051
please help me .
I use uvision Kiel software to program 8051 using C language like this :
unsigned char SerialRecvChar()
{
//initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFD; //to obtain 9600 baud rate
TR1 = 1; //start timer
SCON = 0x50;
//IE= 0x90;
P1= 0x00;
unsigned char i;
while(!RI); //waits till a byte is recieved
RI = 0;
i = SBUF ; //must get SBUF value
return SBUF;
}
but when I run the code to show (i = Sbuf ) then (i) not get the value from SBUF )
please help me .
I use uvision Kiel software to program 8051 using C language like this :
unsigned char SerialRecvChar()
{
//initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFD; //to obtain 9600 baud rate
TR1 = 1; //start timer
SCON = 0x50;
//IE= 0x90;
P1= 0x00;
unsigned char i;
while(!RI); //waits till a byte is recieved
RI = 0;
i = SBUF ; //must get SBUF value
return SBUF;
}
but when I run the code to show (i = Sbuf ) then (i) not get the value from SBUF )