Reading RFID using LPC1769

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading RFID using LPC1769

624 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wannageta on Sun May 31 02:32:26 MST 2015
Hi everyone, I have a problem with reading the RFID tags. Below is the code. it does not print anything... Could anyone please kindly help check where goes wrong....
#include "lpc17xx_pinsel.h"
#include "lpc17xx_gpio.h"
#include "lpc17xx_uart.h"
#include "lpc17xx_nvic.h"
#include "rfid.h"

void init_RFID()
{
PINSEL_CFG_Type PinCfg;
PinCfg.Funcnum= 0;
PinCfg.OpenDrain= 0;
PinCfg.Pinmode= 0;
PinCfg.Portnum= 0;
PinCfg.Pinnum= 2;
PINSEL_ConfigPin(&PinCfg);        //P0.2 RFID ENABLE
PinCfg.Funcnum= 1;
PinCfg.Pinnum= 3;
PINSEL_ConfigPin(&PinCfg);//P0.3 RFID Data Receive

UART_CFG_Type uartCfg;
uartCfg.Baud_rate = 2400;
uartCfg.Databits = UART_DATABIT_8;
uartCfg.Parity = UART_PARITY_NONE;
uartCfg.Stopbits = UART_STOPBIT_1;
UART_Init(LPC_UART0, &uartCfg);

UART_FIFO_CFG_Type FIFOCfg;
FIFOCfg.FIFO_DMAMode = DISABLE;
FIFOCfg.FIFO_Level = 0;
FIFOCfg.FIFO_ResetRxBuf = ENABLE;
FIFOCfg.FIFO_ResetTxBuf = ENABLE;
UART_FIFOConfig(LPC_UART0, &FIFOCfg);

GPIO_SetDir(0, 1<<2, 1);
GPIO_SetValue(0, 1<<2);          //Disable UART as RFID works at active low

NVIC_EnableIRQ(UART0_IRQn);       //Enable Interrupt
UART_IntConfig(LPC_UART0, UART_INTCFG_RBR, ENABLE);
}

int RFID_Compare(char a[], char b[])
{
//if two ID matches, return 1, else return 0
int i=0;
for(i=0;i<12;i++)
{
if(a=b)
return 1;
}
return 0;
}

int main ()
{
int i=0;
int RFIDflag=0;
uint8_t rfidcode [12];//to store the rfid tag
uint8_t correctcode [12];// to store the correct rfid


    GPIO_ClearValue(0, 1<<2); // enable RFID

    UART_Receive(LPC_UART0, rfidcode, 12, BLOCKING); //receive data using UART0

    do
    {
    for (i=0; i<12;i++)
    {
    printf ("%d",rfidcode);
    }
    RFIDflag = RFID_Compare(rfidcode,correctcode);

    } while (RFIDflag == 0);


GPIO_SetValue(0,(1 << 2)); //Disable RFID
    NVIC_DisableIRQ(UART0_IRQn);
0 Kudos
Reply
0 Replies