0% found this document useful (0 votes)
53 views

RFID Reader Programming Instruction

This document discusses how to deal with RFID tag UIDs that include "AA". The first card's UID is returned with "00" added after the "AA". To get the actual UID, remove this extra "00" byte. The second card's UID does not contain "AA" so no modification is needed. It also provides code examples to send commands to an RFID reader and receive the response in an interrupt service routine, handling the added "00" byte if present.

Uploaded by

Zoltán Antal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

RFID Reader Programming Instruction

This document discusses how to deal with RFID tag UIDs that include "AA". The first card's UID is returned with "00" added after the "AA". To get the actual UID, remove this extra "00" byte. The second card's UID does not contain "AA" so no modification is needed. It also provides code examples to send commands to an RFID reader and receive the response in an interrupt service routine, handling the added "00" byte if present.

Uploaded by

Zoltán Antal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

How to deal with UID includes AA

Sample:

Send command to read UID: AABB022022,


First card return: AABB06209A08AA00716F
Second card return: AABB0620028FA90B09

The first card’s UID is “9A08AA71”,so the RFID reader send response of the
command and insert “00” behind the “AA” of the UID, but the length byte is
still 06. So, if you find the is “AA” in the data, then remove one byte of “00” next
to the “AA”. If there are 2 bytes of “00”, just remove the first byte of “00”. For
example, the received data includes “AA0000”, then you just need to remove
one “00”, and save the next “00”, finally the result is “AA00”.
The second card’s UID is “028FA90B”, it has no “AA” inside, so it needs not to
add “00” behind “AA”.
---------------------------------------------------------------------
Send command code example:
void UartSend(unsigned char *cSendBuffer)

unsigned char i;
unsigned char cCheckSum;
TXC = 1;
g_bReceCommandOk = 0;
UDR = 0xAA;
while (!TXC);
TXC = 1;
UDR = 0xBB; // send header AABB
while (!TXC);
cCheckSum = 0;
for (i=0; i<cSendBuffer[0]; i++)
{
cCheckSum ^= cSendBuffer[i];
TXC = 1;
UDR = cSendBuffer[i];
while (!TXC);
if (cSendBuffer[i] == 0xAA)
// if there is a "0xAA" in the data field but not the command header,
// add a "0x00" follow the "0xAA", CL (command length) will not changed.
{
TXC = 1;
UDR = 0; // insert “00” next to the “AA”
while (!TXC);
}
}
TXC = 1;
UDR = cCheckSum; // Send check sum byte
while (!TXC);
TXC = 1;
}
-------------------------------------------------------------------------------------------

Receive code example:


// USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
static unsigned char i;
static unsigned char cReceivedData;
static unsigned char cCheckSum;
char status;
status=UCSRA;
cReceivedData=UDR;

if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)


{
if (g_bReceAA)
{
g_bReceAA = 0;
if (0 != cReceivedData)
{
g_cReceNum = 0; }
}
else
{
if (0xAA == cReceivedData) // get “AA”
{
g_bReceAA = 1;
}
g_cReceBuf[g_cReceNum++] = cReceivedData;
if (g_cReceNum > g_cReceBuf[0])
{
cCheckSum = 0;
for (i=0; i <= g_cReceBuf[0]; i++)
{
cCheckSum ^= g_cReceBuf[i];
}
if (0 == cCheckSum)
{
g_bReceCommandOk = 1; // command success flag set to 1
RXEN = 0;
}
g_bReceAA = 0;
g_cReceNum = 0;
}
if (g_cReceNum >= sizeof(g_cReceBuf))
{
g_cReceNum = 0;
g_bReceAA = 0;
}
}
}
}
//------------------------------------------------------------

Contact Information:
Ehuoyan Co.,Ltd.
Tel: +86-010-80128328
email: [email protected]
Web Site : http://www.ehuoyan.com/english/default.asp

Since 2008, focus on RFID technology.

----------------------------------------------------------------------------------------

You might also like