请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TRF7970A 您好!
我有这个代码、它第一次运行、但第二次运行
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;
}
我必须将其修改为下面的内容、当我再次调用它时、这会起作用、但我不知道为什么上面的连续模式不起作用
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;
}