sam_kevin
Junior Member level 1
- Joined
- Jan 21, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,429
Below is my code for receving data in uart and comparing, if the data matches port bit will get low, but the code is not working kindly help me.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include <reg51.H> sbit sensor = P1^7; unsigned char distance, i; unsigned char dist[8]; void main() { TMOD=0X20; //timer1 mode2 TH1=0XFD; //loading the value to generate baud rate 9600 SCON=0X50; //mode 1 and set REN (Receive enable) bit TR1=1; ES=1; /* Serial interrupt Enable*/ EA=1; /* global interrupt enable*/ while(1); } void serial (void) interrupt 4 { if(RI) { RI=0; dist[i]=SBUF; for(i=0;i<8;i++) { distance= dist[i] ; if (distance == "ABCDEF" ) { sensor=0; } } } if(TI)TI=0; }
Last edited by a moderator: