Issue with getting proper data payload out of ST25DV via I2C after writing to it via NFC.
Lets start with what works...
I can write NDEF payload to ST25DV via I2C and read it back via I2C and using NFC Tools App.... This works fine and perfectly. I can also write NDEF messages using NFC Tools, and read back what I wrote no problem.
The exact issue comes up when I try to read what I wrote to the ST25DV tag (using NFC Tools) using NFC. I don't get garbage exactly... i do get some correct bytes out (the NDEF header is mostly correct), but the payload data portion seems corrupted. What i get from reading via I2C is repeatable...as in I read the same corrupted data with every read. If I write a new NDEF message via I2C, then the corruption no longer exists and I can read back the NDEF message that I wrote (via I2C) without issue.
NFC Tools App allows you to read the memory from the ST25DV. The memory I am reading doesn't match what I read via I2C after I write to the ST25DV using the NFC Tools App. The NFC Tools App seems to have access to a different memory then what the I2C domain does, yet the I2C domain is able to easily write into the NFC domain. This is of course an abstraction for understanding my issue.
There is nothing actually wrong with the ST25DV unit I have on the surface level. It works fine with an Arduino running on STM32L476RG using the st25dv arduino driver (github: stm32duino/ST25DV) without any issues so there as to be some sort of issue with my setup....
In my setup I am using a custom board with Muratta CMWX1ZZABZ-078 that has a STM32L072 on the SoC. The board "B-L072Z-LRWAN1" makes use of this SoC. My I2C lines have other peripherals on it such as a BME280. I can read and write to the BME280 without a problem. My project is based on ( github: Lora-net/LoRaMac-node), of which I inherited all the I2C / Clock settings / API from (building it as if it was a B-L072Z-LRWAN1). I have tried using I2C speeds of 100kHz and 400kHz.
I have an I2C logic analyser. Here's an example of successful read/write using I2C only. I make an NDEF text entry with the string "TestEntry123". Too be clear these transactions work as expected.
write to 0x53 ack data: 0x00 0x04
read to 0x53 ack data: 0x03 0x13
write to 0x53 ack data: 0x00 0x06
read to 0x53 ack data: 0xD1 0x01 0x0F 0x54 0x02 0x65 0x6E 0x54 0x65 0x73 0x74 0x45 0x6E 0x74 0x72 0x79 0x31 0x32 0x33
write to 0x53 ack data: 0x00 0x04 0x03 0x13 0xD1 0x01 0x0F 0x54 0x02 0x65 0x6E 0x54 0x65 0x73 0x74 0x45 0x6E 0x74 0x72 0x79 0x31 0x32 0x33
write to 0x53 ack data: 0x00 0x04
read to 0x53 ack data: 0x03 0x13
write to 0x53 ack data: 0x00 0x06
read to 0x53 ack data: 0xD1 0x01 0x0F 0x54 0x02 0x65 0x6E 0x54 0x65 0x73 0x74 0x45 0x6E 0x74 0x72 0x79 0x31 0x32 0x33
The last line with the read does give me an NDEF message of "TestEntry123" as intended.
Here is the actual I2C signals... again this is the working signals. running at 100kHz.
When read from NFC Tools, 1 record is found. UTF-8 (en) : text/plain "TestEntry123"...as expected. Great that works.
If I used NFC to write the same text entry...i can read it back using I2C...but this seems to be illusion of proper function.
Now here is where my problems begin; I will use NFC Tools to write a DIFFERENT NDEF text entry, and my firmware will just read from the tag via I2C instead of writing anything. I will provide the transactions below. When I read the tag again via NFC Tools, i get the correct text entry data in the app, and when I read the raw memory from NFC Tools, everything looks good and as expected. If I write the same NDEF text message as I written with I2C previously, there is no issue.
In these transactions after I wrote "123TestEntry" via NFC Tools, I simply just read the data from the tag. Again if I just wrote "TestEntry123" (the same as what I wrote via I2C previously), I will be able to read using the same I2C requests below without issue.
write to 0x53 ack data: 0x00 0x04
read to 0x53 ack data: 0x03 0x13
write to 0x53 ack data: 0x00 0x06
read to 0x53 ack data: 0xD1 0x01 0x0F 0x54 0x02 0x65 0x6E 0x10 0x20 0x33 0x54 0x45 0x62 0x74 0x40 0x68 0x30 0x32 0x31
This gives me text output: "0x10 , 0x20 , 3 , T , E , b , t , 0x40 , h , 0 , 2 , 1"
This output is repeatable.
Here is the I2C signal.
Closer look at the clock.
Any help/tips on this issue would be appreciated. Let me know if there is any other kind of analysis you would like to see to help me get to the bottom of this.
