??? 11/19/12 12:17 Read: times |
#188850 - rfid based e toll system |
I've been trying to send commands serially through microcontroller to rfid mifare reader module but cannot send it. Please help me if some one knows about mifare rfid reader . Here is my source code:
#include <reg51.h> #include <string.h> #define FREQ 11059200L #define baudrate 19200L sbit SIG = P3^2; sfr lcd_data_pin=0x80; sbit rs=P2^0; sbit rw=P2^1; sbit en=P2^2; unsigned int data_out,command=0x80,temp; unsigned char card_id[8]; void InitializeSystem(); void Sendcom(unsigned char *g_cCommand); //Command List unsigned char cardserno[5]={0xAA,0xBB,0x02,0x20,0x22}; bit g_bReceReady; void delay(unsigned int count) { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void lcd_command(unsigned char comm) { lcd_data_pin=comm; en=1; rs=0; rw=0; delay(1); en=0; } void lcd_data(unsigned char disp) { lcd_data_pin=disp; en=1; rs=1; rw=0; delay(1); en=0; } lcd_string(unsigned char *disp) { int x; for(x=0;disp[x]!=0;x++) { lcd_data(disp[x]); } } void lcd_ini() { lcd_command(0x38); delay(5); lcd_command(0x0F); delay(5); lcd_command(0x01); delay(5); lcd_command(0x80); delay(5); } void InitializeSystem() { TMOD &= 0x0F; TMOD |= 0x21; SCON = 0x50; PCON |= 0x80; TH1 = (unsigned char) (256 - ((FREQ / 192) / baudrate)); g_bReceReady = 0; TR1 = 1; IE = 0x90; } void main() { unsigned char j; InitializeSystem(); lcd_ini(); lcd_command(0x81); lcd_string("RFID TOLL"); lcd_command(0xC0); lcd_string("COLLECTION SYST."); delay(200); lcd_command(0x01); lcd_command(0x81); lcd_string("SCAN CARD:"); delay(200); Sendcom(cardserno); delay(10); lcd_command(0x01); lcd_command(0x81); lcd_data(card_id[j]); } void Sendcom(unsigned char *g_cCommand) { unsigned char i; do { TI=0; SBUF=g_cCommand[i]; while(!TI); i++; }while(g_cCommand!='�'); g_bReceReady = 1; } seri_int () interrupt 4 using 1 { unsigned char j; if(RI) { RI = 0; if (g_bReceReady) { card_id[j]=SBUF; RI=0; } } if(TI) { TI = 0; } } |
Topic | Author | Date |
rfid based e toll system | 01/01/70 00:00 | |
(back) to basics | 01/01/70 00:00 | |
How to post legible source code | 01/01/70 00:00 |