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.

TRF7970A: Problems with reading ISO14443a tag UID with TRF7970A

Part Number: TRF7970A


Hello,

I am working on the firmware for stm32f103. I am using SPI with SS to connect with TRF7970a chip. SPI speed is 2 MHz. My goal is to read UID of Mifare Ultralight tag.

I successfully managed to read(+continiuos read) and write(+raw write) registers of TRF and sending commands.

I was working on porting your "TRF7970 Reader Demo" (sloc297c) example project to make it work with STM32F103 MCU, but unfortunately it doesn't work correctly for me.

 

Now I am trying to follow the sequence to get the UID of Mifare Ultralight 512 Tag, but I have stucked, reading "IRQ Status" register after sending "REQA" command to TRF.

Here is my sequence to initialize TRF for reading ISO14443A type tag:

1) TRF_sendDirectCommand(TRF7970A_CMD_SOFT_INIT);

2) TRF_write(TRF7970A_MODULATOR_SYS_CLK_CTRL, 0x21); // VDD = 5V, Vio = 3.3V

3) TRF_write(TRF7970A_ISO_CTRL, 0x88);                                  // ISO14443A no CRC

4) TRF_write(TRF7970A_CHIP_STATUS_CTRL, 0x21);              // turn RF on -> current from power supply increases (12V, 0.05A)

5) Send raw "REQA" command. -> rawWrite ([0x8F 0x90 0x3D 0x00 0x0F 0x26])

6) Delay 10 ms

7) Read "IRQ Status" + dummy read. ->  I get [0xFF, 0xFF] from "IRQ  status (expect to get [0xC0, 0x3E])

8) Read "FIFO Status" -> I get [0xFF] (expect to get [0x02])

9) ...

So, after step 5 (REQA raw write) IRQ Pin of TRF7970 goes HIGH and doesn't come LOW, even after "IRQ Status" register reading.

The values I get from "IRQ Status" and "FIFO Status" are not expected. I can't continue to next steps (getting UID by raw writing "AntiColl" command).

Can you please tell me what are my mistakes, why I can't get correct IRQ status and why does IRQ pin not goes LOW after interrupt. It might I have missed something, but I couldn't deal with it yet.

Regards,

Demian Z

  • Hello Demian,

    Are you reading the IRQ pin as soon as it pulses high? If not, I would recommend doing so by either polling or setting up an ISR on rising edge.

    Reading IRQ status as you described should clear the interrupt and certainly shouldn't return an FF.

    Which registers have you tried reading to ensure the read commands are working?

    Also, are you writing to register 0x18 to clear it to 0x00 per TRF7970A errata?

  • Hello Ralph, thanks for your answer.

    It seems like things moved a little, but now I have another problem.

    I managed to handle the interrupt from IRQ pin. I added dummy write (sending 0x00 to SPI line) after rawWrite([0x8F 0x90 0x3D 0x00 0x0F 0x26]) and it seems working correctly.

    Now, after "REQA" command I get next values:

    1. If there is no tag in the field, I read [0x3E, 0x80] values from TRF7970A_IRQ_STATUS register. If there is a Mifare Ultralight tag in the field, I get [0x3E, 0xC0] bytes.

    2. Then I read [0x40] from TRF7970A_FIFO_STATUS regiser (with and without tag in the field).

    Then, I try to read TRF7970A_FIFO_IO_REGISTER but get only [0x00] values. Expect to get ATQA [0x04 0x00].

    After that I reset FIFO and read RSSI_OSC_STATUS reg.

    After that, I try to send AntiCollision command by rawWrite([0x8F 0x90(tried 0x91) 0x3D 0x00 0x20 0x93 0x20]) and handle new interrupt, but nothing happens. TRF IRQ pin doesn't go HIGH and I can't get correct UID values from FIFO_IO_REGISTER.

    Can you please tell me again, what I could miss?

    P.S.: Answering your questions: 1. I tried to write and read almost all registers, so I think my functions work correctly. 2. I added TRF_write(TRF7970A_NFC_TARGET_LEVEL, 0x00) function in my loop after writing ISO_CTRL(0x88) - (after step 3 in my previous post).

    Will be glad to hear from you again.

    Regards,

    Demian Z

  • Hello Demian,

    You shouldn't need to send a dummy write after a packet transmission, so I suspect something is still off with your MCU -> TRF7970A setup.

    Are you clearing the FIFO after you receive TX complete?

    By the way if you really are porting SLOC297 correctly, you should have had the initialization sequence with all register writes correct.

    Please review SLOC297 in great detail and ensure your software incorporates all correct handling for: Startup/configuration, TX/RX IRQ processes, Erroneous IRQ reports, and device software resets.

    The example code was made to handle all the required operation for the device, and based on your comments so far, I can only assume you haven't properly ported key device handling processes.

  • Hello Ralph.

    Okay, now I am trying to use only sloc297c library without my "raw" sequences.

    I ported all sloc297 functions and interupt handlers. Tested spi single/continous read/write functions with different registers, they work good. All init functions are ported too.

    I didn't change/delete source sloc297 functions, only implementation for stm32, and everything seems working before AntiColl. If I place a breakpoint inside NFC_findTag(), for examle in the begining of anticoll cmd function, it triggeres only when I put card in the field, as it should do.

    So, now I get ATQA response from TRF7970 after sending REQA command, and interrupt[0x40] is handled correctly. I get [0x02] from FIFO Status, and then get [0x44 0x00] from FIFO.

    After that comes ISO14443A_sendAnticollisionCmd function. After rawWrite[0x8F 0x90 0x3D 0x00 0x20 0x93 0x20] it comes TRF79xxA_waitRxData and here is where I stuck. There is no interrupt/response from TRF after AntiColl command. Tried different rx/tx timeout configuritations for TRF79xxA_waitRxData,

    Here is oscilloscope data for sending anticoll cmd, Yellow-clk, blue-miso:

    So I get only two interrupts on IRQ pin while findTag loop (if there is card in field):

    If there is no card - one interrupt.

    So, can you please tell, what can be the problem now? Why there is no response after AntiColl cmd?

    Demian Z

  • Hello Demian,

    That you get two interrupts with a tag and one without a tag sounds like the correct behavior. The interrupt you always get is for the TX Complete, and then it seems you get some sort of RX interrupt when you have a tag present. What would be important to know now would be what the IRQ status from that second interrupt is, as it would indicate if there is received data or if an error occurred.