This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to read NDEF-Data from a RF430-Tag with a TRF7960-Reader

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;
}


  • Bernd -
    after tag is selected (meaning you received answer to ATTRIB command) and you don't want to change the data rate (meaning you leave it at 106kbps)

    You would then send:

    1. NDEF Application Select() // Selects NDEF Application
    2. CapabilityContainerSelect(); //Selects the Capability Container
    3. ReadBinary(0, 15); //for contents of the capability container
    4. SelectNDEF(); //Selects NDEF Application
    5. ReadBinary(0, 02); //reads NDEF Application for length of message
    6. ReadBinary(2, len); //for NDEF content, with offset of two bytes, since you already know length

    are you wanting to write code or just use GUI or terminal program to send these out? Let us know, and we can send you what you need based on your answer.
  • Hallo Josh,

    thank you for your reply. I write the code as a part for a whole System. I use a MSP430F5529 which controls the System:

    The System should Charge sensors (Wirless-Power), read out their Data over NFC, set new Sensor-Parameters. To do this, the MSP430 has a WiFi or USB-Connection to other Computers. ...

    But back to my problem:

    I Need to know

    1. what Settings the TRF7960-Register should have.

    2. What Data should be written in the FiFo. What Responses come back.

    At first it is ok to stay at 106kbps. I also hope, that I don't Need to Change the Settings from TRF7960 because it Looks that I get a answer to the ATTRIB command.

    So what Bytes has to be send for the Steps 1 to 6 you wrote. What answers come back from the RF430?

    In my first post was a C-File with the code-part I use to Send the REQ and ATRRIB command. I Need something similar vor the steps 1 to 6 you wrote.

    Best regards

    Bernd E.

  • got it -

    i have attached  four files which i use on MSP430G2553 to drive TRF7970A on the boosterpack

    should be able to see now what to do, starting with you looking at the iso14443b.c file in the line 99 if (tag found) and following the flow to the functions.

    ISO14443B_and_NDEF.zip

  • Hallo Josh - Thank you again.

    I will give it a try on Wednesday when I'm back in Office. I've had a short look into the files and got a question to the Interrupt-Routine responding to the TRF7960 Interrupt.
    In my Software only the flag got set and the rest is done in the 'normal' Programm. But in your Interrupt-Software seems to more work.

    Is it right, that I first have to read the TRF79X0_FIFO_STATUS_REG and than read the Response with
    TRF79x0_readCont( buf, TRF79X0_FIFO_REG, xx); where xx is the value of the TRF79X0_FIFO_STATUS_REG?

    Do you have any idea why I get an Interrupt-Signal, read the Interrupt-Status (value = 0x40) and the value of the FIFO_STATUS_REG is still 0?

    I also noticed, that there are 2 Functions: ReadBinary and ReadBinary2
    So when use ReadBinary and when ReadBinary2?

    Last question for now: After a call to UpdateBinaryLength2() and UpdateBinary() should the RF430-NDEF-Data have a link to ti.com?

    Best regards

    Bernd E.
  • Hallo Josh,

    thank you for your help. Because of your help is my System able to Exchange NDEF-Data.
    I got another question: My System should also support ISO15693 Tags and P2P.
    Is the way of NDEF-Data Exchange by an ISO15693-Tag similar to ISO14443b? What I mean is, is thare a way to Select the Tag and then use our NDEF-Code for the NDEF-Data-Exchange?

    Best regards
  • Bernd -
    Yes - put this together for that. ==> www.ti.com/.../sloa166a.pdf