??? 06/20/09 10:03 Read: times |
#166278 - working code Responding to: ???'s previous message |
#include <REGX52.h> //program care stocheaza si compara(bun) #define Baud_rate 0xF4 char i=0,j=0,buf[12],var[10],buf2[10]; bit aux=0; char contor; init(){ TMOD=0x20; SCON=0x50; TH1=Baud_rate; TL1=Baud_rate; EA=1; ES=1; TR1=1; } void main(){ contor=0; buf2[0]=0x30;buf2[1]=0x34;buf2[2]=0x31; buf2[3]=0x35;buf2[4]=0x44;buf2[5]=0x38; buf2[6]=0x41;buf2[7]=0x31;buf2[8]=0x46; buf2[9]=0x031; P2_0=0; init(); while(1); } void serial_IT(void) interrupt 4 { if(RI){ buf[i]=SBUF; //delay(100); RI=0; } if(i<12) i++; else{ i=0; if(buf[0]==0x0A){ P2_1=0; if(buf[11]==0x0D){ P2_2=0; for(j=0;j<9;j++){ var[j]=buf[j+1]; if(var[j]!=buf2[j]) aux=1; } } } if(aux==0){ P2_3=0; } } } this is a working code for reading a tag and compare it with the one in memory...how can i modify it to be able to read more tags(at the moment after reading a tag,valid or not,and lighting the right leds the program stops working and i am not able to read another tag) |