cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, Im using ST25DV04 with ESP32. Im unable to write tags onto NFC. I2C Communication fails.

Shruthi
Associate II

0693W00000DpfBTQAZ.jpgDuring initialization of CC, as I understand we should have values 0xe1,0x40,0x40,0x00

But I am getting 0xe1,0x40,0x40,0x43. Im trying to manually write 0xe1,0x40,0x40,0x00 at address 0xa6, 0x00 which is failing.

I ignored that and tried to write a text NDEF tag to it which is also failing.

Please check the screenshot.

Step1 : Im writing CC at 0xa6,0x00 address- which failed.

Step2 : Writing length at 0xa6,0x04 address - success

Step3 : writing text NDEF tag at 0xa6,0x06 address - fail

Step4 : reading NDEF data- reading old text NDEF tag present on NFC.

Why is the write operation failing ? Are there any other registers to be set before writing?

15 REPLIES 15

sent the file over mail.

Hi,
Here is the scope data when I run the entire NFC_init() function.
Starting from reading NFC ID, till writing my custom Media type tag.
JL. Lebon
ST Employee

Hello Shruthi,

Thank you for the trace, it really helps to understand the issue.

Your I2C trace shows that the I2C writes are not correctly framed.

In the Session_I2C_Init trace, you can see that starting at time 3172501208.

Your write frame is this:

Start/A6/Ack/00/Ack/04/Ack/03/Ack/Start/A6/Ack/C1/Ack/Stop.

I guess you are trying to write value 03h at address 0004h, and then value C1h.

There is two things wrong in this sequence:

  • An I2C write MUST be terminated by a STOP bit. After the byte 03h, you do a new START, so the write value 03h at address 0004h is not executed
  • After the second START bit, you present the device select slave address, and then what seems to be a value to be written. But after the START, the ST25DV assumes this is a new write sequence, and is waiting for a memory address on 2 bytes at this place. So the write of value C1h is not executed

This is all explained in detail in datasheet chapter "6.4 I2C Write operations".

Correct sequence is:

Start/A6/Ack/00/Ack/04/Ack/03/Ack/C1/Ack/Stop.

or, if you want to do it in 2 times:

Start/A6/Ack/00/Ack/04/Ack/03/Ack/Stop Start/A6/Ack/00/Ack/05/Ack/C1/Ack/Stop.

The next write sequences all suffer from the same problem, and this is why no data is ever written to the tag's memory.

Best regards.

Hello,
Thanks much for the support. I corrected the I2C sequence and I'm able to write the tag onto NFC now.
But after writing the tag, the last terminator byte 0xfe is failing. while addressing the device itself, there is no acknowledgment.
Saleae is used.
Ch0-SCL ; Ch1 - SDA
JL. Lebon
ST Employee

Hello,

"While addressing the device itself, there is no acknowledgement": do you mean after the first byte (the device slave address) there is not acknowledgement ?

This means that the device is not available for processing an I2C command. This can happen in 3 cases:

  • the device is not powered with Vcc.
  • the device is busy on the RF interface, processing an RF command.
  • the device is busy writing data into EEPROM after an I2C write command.

I guess you may be in the third case. I suppose you are writing the terminator TLV right after updating the NDEF message content ?

When updating the NDEF message, you are writing into the EEPROM memory. The I2C bus is then unavailable during the programming time of the EEROM: the device needs 5ms to program each 4 bytes of data. The write is starting at the stop bit of the I2C write command.

So, you should wait the end of EEPROM programming before being able to access the tag again.

This is explained in the datasheet, in chapter "6.4.2 I2C Sequential write".

Best regards.

Shruthi
Associate II

Got it. Thanks a lot for the support.