hi i am connecting a simple passive rfid reader(with no additional features) to my microcontroller ds89c450(8051 compatible) , i have written a code for it for this my rfid reader reads a tag and gives out 10 digits,it has rs232 connection, so i am connecting my rfid reader with a rs232 db9 connector to my microcontroller( i am using built in kit for microcontroller so my rs232 stuff is built in for both) i have pasted my code below i have attached some leds to see the progress of my code on kit as i observed running it ......... i found out tht if we take negative logic only led2 gets on led 1 gets on but after sometime ,???even if i dont bring any tag nearby???? led3 ,4 never switches on i have been able to analyze tht my init function running but wht abt others plzz help me out , wht might be the prblm finally wht i can say is i sucessfully tested on keil this one is working 100%(even in debugging stg)
#include<reg420.h> #include<string.h>
sbit buz1=P2^3; sbit tagsw=P3^6; sbit led1=P2^4; sbit led2=P2^5; sbit led3=P2^6; sbit led4= P3^2;
init(); void rfid_num(); void tagfunc(); char *loc;
void main() {
buz1=0; init();//used to initialize my microcontroller
while(1) {
while (RI_1==0);// am waiting for an receive interrupt led1=0;//test led rfid_num();// as we receive i am calling this function }
}
init() { led2=0; TMOD=0x21; TH1=0xFD;
TR1=1;
return ; }
void rfid_num()
{ char *aradd,i ,tagno[10];//taking an array to store my tag no char *a= "34006CC5AA";//these are the tag nos
char *b= "34006CD97F";
char *c= "34006C8CA1";
char *d= "34006C6D26";
char *e= "34006CAC2F";
char *f= "34006C6170";
led3=1;
aradd=&tagno[0];
led3=0;
for(i=0;i<=9;i++)// i take up all nos in the tag
{ while(RI_1==0);
*aradd=SBUF1;
RI_1=0;
aradd++;
ES0=1;
if(!strcmp(aradd,a))// i am comparing here the present one with predefined for my future purpose in my educatioal project
{
led4=0; }
else if(!strcmp(aradd,b)) {
else if(!strcmp(aradd,c)) {
else if(!strcmp(aradd,d)) {
else if(!strcmp(aradd,e)) {
else if(!strcmp(aradd,f)) {
} tagfunc(); ES0=1; return;
void tagfunc()// i call this function from rfidnum func { buz1=1;
if(tagsw==0) { while(tagsw==0);
} else { while(tagsw==1);
} buz1=0;