Part Number: TRF7970A
Hi,
I have this code which works the first time around but not the second
void RFIDReadDataBlock(unsigned char startAddress, unsigned char numBytes)
{
unsigned char Local_8;
unsigned char i;
unsigned char commandAddrByte = 0;
commandAddrByte |= 0x60; // Set the 'read' and 'continuous' bits
commandAddrByte |= (startAddress & 0x1F); // AND in the lower 5 bits of the address
SPI2Init(RFID_WRITE);
RFID_CS = 0; // Activate chip select
Local_8 = writeSPI2(commandAddrByte); // Send the address
for(i = 0; i < numBytes; i++)
{
Local_8 = writeSPI2(0); // Read back the data
spiBlockReadBuf[i] = Local_8;
}
RFID_CS = 1; // Deactivate the chip select
return;
}
I've had to modify it to below and this works when I call it a second time but I don't know why continuous mode above doesn't work
void RFIDReadDataBlock(unsigned char startAddress, unsigned char numBytes)
{
unsigned char Local_8;
unsigned char i;
unsigned char commandAddrByte = 0;
commandAddrByte |= 0x40; // Set the 'read' bit
commandAddrByte |= (startAddress & 0x1F); // AND in the lower 5 bits of the address
SPI2Init(RFID_WRITE);
RFID_CS = 0; // Activate chip select
for(i = 0; i < numBytes; i++)
{
Local_8 = writeSPI2(commandAddrByte); // Send the address
commandAddrByte = commandAddrByte + 1;
Local_8 = writeSPI2(0); // Read back the data
spiBlockReadBuf[i] = Local_8;
}
RFID_CS = 1; // Deactivate the chip select
return;
}