Other Parts Discussed in Thread: TRF7960, MSP430F5529, MSP430G2553, TRF7970A
Hello E2E community
I programmed a RF430-Tag with NDEF-Data. This Tag is readable with Tablet / Smart-Phone.
Now I like to read that Tag with a TRF7960-Reader. I tried different Software from TI but without success. By now my MSP430-Software comes to a point where it:
Send RFQB and gets ATQB
Send ATTRIB and gets a answer.
But after this I get stuck:
Should I send B2 which is coded as:
0x00, 0xB2, 0x00, 0x00 as a ISO7816-read records-CMD or should I only send 0xB2?
Normal ISO7816-cmds seems to respond with SW1 SW2 but so far I don't come. According to page 30 of the RF430CL330 datasheet the response should be A2. What does that mean?
It would be helpful if someone could tell me the correct Byte-Sequence which has to be written in the TRF7960-Registers and especially to the FiFo or read from the FiFo.
I also wonder why the TRF7960 gives a RX-interrupt (TRF79X0_IRQ_STATUS_REG =0x40) but when I ask the TRF79X0_FIFO_STATUS_REG it is 0x00. Can someone explain that please?
Here a part of that Code:
uint8_t buf[10];
while (!isNFC_IRQ_ACTIVE) ; // wait for IRQ
TRF79x0_readSingle( buf, TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x40) // Check vor Receive
NFC_ErrorDebug();
do // wait for Data
TRF79x0_readSingle( buf, TRF79X0_FIFO_STATUS_REG);
while( buf[0] < 1);
… don’t come here
I'm out of Office till Wednesday – so if I don't respond to your questions it doesn't mean that your reply isn't welcome.
Best regards
Bernd E.
#include "Hardware.h"
#include "trf79x0.h"
uint8_t mbPUPI[4]; // Hier Pupi speichern
uint8_t mbCI; // Hier CI (PICC: Compliance Info)
extern volatile uint8_t g_ui8IrqFlag;
extern volatile uint8_t g_ui8TimeOutFlag;
extern uint8_t g_ui8FifoBuffer[255];
extern void MCU_timerDisable(void);
extern void MCU_timerInit( uint16_t ui16TimeOut);
extern void TRF79x0_readSingle( uint8_t * pui8Value, uint8_t ui8Register );
extern void TRF79x0_readCont( uint8_t * pui8Payload, uint8_t ui8Register, uint8_t ui8Length );
extern void TRF79x0_directCommand(uint8_t ui8Command);
void NFC_ErrorDebug(void)
{
_NOP();
}
void NFC_SetProtokoll(void)
{
uint8_t buf[4];
buf[0] = 0x00; // Register 0 Chip-Status = 21
buf[1] = 0x21;
buf[2] = 0x01; // ISO-Control = 0C
buf[3] = 0x0c;
TRF79x0_rawWrite(&buf[0], 4);
DELAY_ms(220);
TRF79x0_readSingle( &buf[0], TRF79X0_CHIP_STATUS_CTRL_REG);
if (buf[0] != 0x21)
NFC_ErrorDebug();
TRF79x0_writeSingle( 0x21, TRF79X0_CHIP_STATUS_CTRL_REG);
DELAY_ms(100);
TRF79x0_readSingle( &buf[0], TRF79X0_CHIP_STATUS_CTRL_REG);
if (buf[0] != 0x21)
NFC_ErrorDebug();
TRF79x0_writeSingle( 0x21, TRF79X0_CHIP_STATUS_CTRL_REG);
}
void NFC_ISO14443_REQ_1_Slot(void)
{
TRF79x0_writeSingle( 0x20, TRF79X0_MODULATOR_CONTROL_REG);
// Reset, Transmission mit CRC, Write Cont ab 1D, Length-Byte 1=0, Length-Byte 2=30, FiFo-IO=5, ?0?
uint8_t buf[12] = {0x8F, 0x91, 0x3D, 0x00, 0x30, 0x05, 0x00, 0x08 };
TRF79x0_rawWrite(&buf[0], 8);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ (754�s)
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x80) // Check vor Transmission beendet
NFC_ErrorDebug();
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ (2,3ms)
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (!(buf[0] & 0x40)) // Check vor Read beendet
NFC_ErrorDebug();
do
TRF79x0_readSingle( &buf[0], TRF79X0_FIFO_STATUS_REG);
while( buf[0] < 12);
TRF79x0_readCont( buf, TRF79X0_FIFO_REG, 12); // Lese ATQB-Response
if (buf[0] == 0x50)
{
mbPUPI[0] = buf[1];
mbPUPI[1] = buf[2];
mbPUPI[2] = buf[3];
mbPUPI[3] = buf[4];
mbCI = buf[10] & 0x0F;
}
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
}
void NFC_ISO14443_Attrib(void)
{
uint8_t buf[] = { 0x8F, 0x91, 0x3D, 0x00, 0x90, 0x1D, mbPUPI[0] , mbPUPI[1], mbPUPI[2], mbPUPI[3], 0, 0x52, mbCI , 0x00 };
TRF79x0_rawWrite( buf, 14);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ (0,63ms)
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x80) // Check vor Transmit
NFC_ErrorDebug();
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ jetzt Empfang (0,63ms)
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x40) // Check vor Receive
NFC_ErrorDebug();
do // Warte bis 3 Byte im FiFo
TRF79x0_readSingle( &buf[0], TRF79X0_FIFO_STATUS_REG);
while( buf[0] < 1);
TRF79x0_readCont( buf, TRF79X0_FIFO_REG, 1); // Lese Atrrib-Response
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD); // 2,24ms
}
void NFC_144443b_ReadBlock(uint8_t bBlockNo, uint8_t bData[18])
{
uint8_t buf[] = { 0x8F, 0x91, 0x3D, 0x00, 0x30, 0x20, 0x02 };
TRF79x0_rawWrite( buf, sizeof(buf));
while (!isNFC_IRQ_ACTIVE) ; // Warte auf Tx-IRQ
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x80) // Check vor Transmit
NFC_ErrorDebug();
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ jetzt Empfang
TRF79x0_readSingle( &buf[0], TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x40) // Check vor Receive
NFC_ErrorDebug();
do // Warte bis 3 Byte im FiFo
TRF79x0_readSingle( &buf[0], TRF79X0_FIFO_STATUS_REG);
while( buf[0] < 18);
TRF79x0_readCont( bData, TRF79X0_FIFO_REG, sizeof(bData)); // Lese Atrrib-Response
}
uint8_t NFC_sendByte(uint8_t b)
{
uint8_t buf[] = { 0x8F, 0x91, 0x3D, 0x00, 0x10, b };
TRF79x0_rawWrite( buf, sizeof(buf));
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ (0,63ms)
TRF79x0_readSingle( buf, TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x80) // Check vor Transmit
NFC_ErrorDebug();
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
while (!isNFC_IRQ_ACTIVE) ; // Warte auf IRQ jetzt Empfang (0,63ms)
TRF79x0_readSingle( buf, TRF79X0_IRQ_STATUS_REG);
if (buf[0] != 0x40) // Check vor Receive
NFC_ErrorDebug();
do // Warte auf Daten
TRF79x0_readSingle( buf, TRF79X0_FIFO_STATUS_REG);
while( buf[0] < 1);
TRF79x0_readCont( buf, TRF79X0_FIFO_REG, 1); // Lese Atrrib-Response
return buf[0];
}
uint8_t NFC_ProcessCMD( uint8_t bINS, uint8_t bPAR1, uint8_t bPAR2, uint8_t *bBuf, uint16_t bLenTX, uint16_t bLenRX)
{
uint16_t bTxLen = 4+bLenTX;
uint8_t buf[] = { 0x8F, 0x91, 0x3D, (uint8_t)(bTxLen>>4), (uint8_t)(bTxLen<<4), 0x00, bINS, bPAR1, bPAR2 };
TRF79x0_rawWrite( buf, sizeof(buf));
TRF79x0_rawWrite( bBuf, bLenTX);
g_ui8TimeOutFlag = 0;
MCU_timerInit(10); // Timeout 10ms
while (!isNFC_IRQ_ACTIVE && !g_ui8TimeOutFlag) ; // Warte auf Tx-IRQ
TRF79x0_directCommand(TRF79X0_RESET_FIFO_CMD);
bLenRX += 2; // Erwartete Datenl�nge + 2 f�r SW1 und SW2
while (!isNFC_IRQ_ACTIVE && !g_ui8TimeOutFlag) ; // Warte auf Rx-IRQ
do // Warte bis gew�nschte Anzahl Bytes im FiFo / oder Timeout
TRF79x0_readSingle( &buf[0], TRF79X0_FIFO_STATUS_REG);
while( buf[0] < bLenRX && !g_ui8TimeOutFlag);
if (buf[0]>0)
TRF79x0_readCont( bBuf, TRF79X0_FIFO_REG, buf[0]); // Lese Card - Antwort
return buf[0];
}
uint8_t NFC_ReadRecords(void)
{
uint8_t buf[10];
uint8_t bResult = NFC_ProcessCMD( 0xB2, 0x00, 0x00, buf, 0, 8);
return bResult;
}
// not yet implemented
uint8_t NFC_ReadEnvelope(void)
{
uint8_t bResult = 0;
return bResult;
}
uint8_t NFC_SelectFile()
{
uint8_t bResult = 0;
return bResult;
}
uint8_t NFC_ReadBinary()
{
uint8_t bResult = 0;
return bResult;
}
uint8_t NFC_14443b_Find_Tag(void)
{
NFC_SetProtokoll();
NFC_ISO14443_REQ_1_Slot();
NFC_ISO14443_Attrib();
uint8_t b = NFC_sendByte(0xB2);
if (b != 0xA2)
NFC_ErrorDebug();
if (NFC_sendByte(0xC2) != 0x02)
NFC_ErrorDebug();
NFC_ISO14443_REQ_1_Slot();
NFC_ISO14443_Attrib();
if (NFC_sendByte(0xB2) != 0xA2)
NFC_ErrorDebug();
NFC_ReadRecords();
NFC_ReadEnvelope();
NFC_SelectFile();
NFC_ReadBinary();
return 0;
}