??? 06/15/09 12:26 Modified: 06/15/09 13:55 Read: times |
#166087 - Still not out of time for C Responding to: ???'s previous message |
i've missed the deadline for my project but my teacher gave me another shot at it and we both decided i should try to write the program in Keil as i wasn't able to do it in assemble. So if you still want to help me please do. I remind u that i have a 89s52 controller conected to a rfid card reader.The reader provides a 12 bytes ID (0x0A+10 data bytes+0x0D)from a tag that is swiped in front of it. I have to compare the ID received from reader with one stored in memory .
For the moment i only wrote a small program that glows a led if i receive something from the reader #include <REGX52.h> #define Baud_rate 0xF4 void main(){ TMOD=0x20; SCON=0x50; TH1=Baud_rate; TL1=Baud_rate; TR1=1; while(1){ while(RI==0); P1_0=0; RI=0; } } Now i want to write a code for reading an ID,checking if it starts with 0A and ends with 0D,store the rest 10 bytes and glow a led at the end of this operations but it is not working.Pls help me. #include <REGX52.h> #include<string.h> #define Baud_rate 0xF4 init(); void store(); void main(){ init(); while(1){ while(RI==0); //waiting for receive P1_0=1; store(); } } init(){ TMOD=0x20; SCON=0x50; TH1=Baud_rate; TL1=Baud_rate; TR1=1; return; } void store(){ char *var,i,tagno[10]; while(RI==0); *var=SBUF; RI=0; if(var==0x0A){ //check if first byte is 0x0A var=&tagno[0]; for(i=0;i<9;i++){ while(RI==0); *var=SBUF; RI=0; var++; } while(RI==0); *var=SBUF; RI=0; if(var==0x0D){P1_0=0;} //check if last byte is 0x0D } } |