Toll-Free Customer Support 24/7

RFID Reader - Serial


/*
* Project name:
RFID Reader - Serial
* Copyright
(c) Researchdesignlab.com
* Description:

* Test configuration:
MCU: AT89S52
Dev.Board: 8051
Oscillator: 11.0592 MHz
Software: Keil uVision3

*/


#include"reg51.h"
#include"string.h"
#define LCD_PORT P2
sbit rs=P3^5;
sbit en=P3^7;
sbit D7=P2^7;
sbit rw=P3^6;

unsigned char SCI_ReceiveByte( void );
unsigned char byte;
void busy();
void CMD_WRT(unsigned char);
void LCD_WRT(unsigned char *);
void DATA_WRT(unsigned char);
void DELAY();

void main()
{
unsigned char CMD[]={0x38,0x0F,0x01,0x06,0x80},i,TEMP;

DELAY();
TMOD=0X20;
TH1=0XFD;
SCON=0X50;
TR1=1;
DELAY();
for(i=0;i<=4;i++)
{
TEMP=CMD[i];
CMD_WRT(TEMP);
}


while(1)
{

byte=0;
DELAY();
DELAY();

CMD_WRT(0X80);
LCD_WRT(" RFID Reader...");
CMD_WRT(0XC0);
while(byte!=10)
{
byte=SCI_ReceiveByte();
DATA_WRT(byte);
}
DELAY();
DELAY();
DELAY();


}
}


void busy()
{
D7=1;
rs=0;
rw=1;
while(D7!=0)
{
en=0;
en=1;
}
}

void CMD_WRT(unsigned char val)
{
busy();
LCD_PORT=val;
rs=0;
rw=0;
en=1;
en=0;
}

void LCD_WRT(unsigned char *string)
{
while(*string)
DATA_WRT(*string++);
}
void DATA_WRT(unsigned char ch)
{
busy();
LCD_PORT = ch;
rs=1;
rw=0;
en=1;
en=0;
}
void DELAY()
{
unsigned int X=60000000;
while(X--);
}

unsigned char SCI_ReceiveByte( void )
{
unsigned char byte;
while(RI!=1);
byte = SBUF;
RI=0;
return byte;
}

Back to top