- This topic has 5 replies, 2 voices, and was last updated 7 years, 1 month ago by .
Viewing 6 posts - 1 through 6 (of 6 total)
|
Microcontroller › PIC › How to interface RFID with PIC18F4550 Microcontroller
// Program to interface RFID module using EUSART in PIC18F4550
// Configuration bits
/* _CPUDIV_OSC1_PLL2_1L, // Divide clock by 2
_FOSC_HS_1H, // Select High Speed (HS) oscillator
_WDT_OFF_2H, // Watchdog Timer off
MCLRE_ON_3H // Master Clear on
*/
#define FREQ 12000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)
#define rs LATA.F0
#define rw LATA.F1
#define en LATA.F2
#define lcdport LATB
unsigned char rx_data();
void lcd_ini();
void lcdcmd(unsigned char);
void lcddata(unsigned char);
unsigned char data[]="Unique ID No.";
unsigned char card_id[12];
unsigned int i=0,pos;
void main()
{
TRISB=0; // Set Port B as output port
LATB=0;
TRISA=0;
LATA=0;
SPBRG=spbrg_value; // Fill SPBRG register to set the baud rate
RCSTA.SPEN=1; // To activate serial port (Tx and Rx pins)
RCSTA.CREN=1; // To enable continuous reception
PIE1.RCIE=1; // To enable the Reception (Rx) Interrupt
INTCON.GIE=1;
INTCON.PEIE=1;
lcd_ini(); // LCD initialization
while(data!='