Microcontroller › 8051 › the function of the code “SBUF = value”.in RS232 interfacing code by som9543 › Hi thereI guess the above
October 9, 2016 at 11:06 am
#14189
GANEEV SINGH
Participant
Hi there
I guess the above code is not correct, shouldn't it be:
void recieve() //Function to receive serial data
{
unsigned char value;
while(RI==0); //waits untill any reception occurs
value=SBUF; //stores 1 byte data in value
P1=vlaue; //that value is also copied to PORT1
RI=0; //makes RX part get ready for another reception
}
At the end of this function you could also add SBUF=0;(just after RI=0;) to ensure no garbage value stays inside SBUF register, which might have affected the upcoming reception.