Hello, in my project work I want to read serially received data continuously and compare it with stored ID in MCU I am using 8051. If the ID match then Green LED will glow, for ID mismatch Orange LED. If no ID found Red LED should glow. In this I am getting problem,when valid Id received it is indicated by Green LED but if we stop sending ID i.e. logically NO DATA in SBUF the Red LED should glow ; it doesn't happen its showing Green Led on...how to solve this one?
Think!
Thinking...thinking..... on peak point of project..need help from Experts!!
How do you you identify when something has been received...?
Think, then, about what criteria could be applied to determine that nothing has been received...
Look at all the facilities (peripherals) in your chip - which of those do you think could help...?
Here is code
/* /Program to interface RFID with 8051 microcontroller (AT89C51) Program receiving character/Tag ID serially and security alarm system baud rate 9600, no parity, crystal freq 11.0579 Mhz*/
#include <REGX51.H> sbit s10 = P1^0; sbit s11 = P1^1; sbit s12 = P1^2; sbit s13 = P1^3;
void green_led_on() { SBUF='*'; s12=1; s13=1; s10=0; s11=0; }
void red_led_on() { s10=1; s11=1; }
void main( ) { char recID; P2=0x00; P1=0x00; P0=0x00; TMOD=0x20; TH1=0xfD; TR1=1; SCON=0x50; IE=0x90; RI=1; while(1) { if (RI=='1') { recID=SBUF; RI = 0; if(recID==55) { green_led_on(); }
else if(recID==10) { green_led_on(); }
else if(recID==74) { green_led_on(); }
else if(recID==104) { green_led_on(); }
else { red_led_on(); } } } }
"need help from Experts"
Harzel Dimbaar is your man, bro.
thanks man,. you are not the elephant with one tusk
start a timer when ever u get a char with da RI
if timer gets to high u know u have not rx anything for a time
then u can light da led to say "notghing rx"
has da cpu got a good timer for this?
View all questions in Keil forum