2024-09-13 01:04 AM
Hello everyone,
I'm working with the Nucleo NFC07A1 board, which mount the ST25DV64KC chip, to create a simple Tag-Reader system. At the moment, I'm testing the ST25 with my smartphone, using the ST25 Android app.
A user from the ST community suggested I use the "Send Custom Command" function on the Android app to send commands via the RF antenna coils.
I started with simple commands, and they worked fine. For example, I was able to read and write to the EEPROM and check the configuration of some registers, all without any issues.
However, when I try to use the Mailbox read and write commands, nothing seems to work. Here's what I did:
Next, I sent the following message through the "Send Custom Command" menu using this configuration:
Command: 20 CA 02 0B D2 15 76 66 51 02 E0 03 11 22 33 44
The tag responds with one of these two error messages:
However, I’m sure tag and smartphone are connected, as the interrupt on GPO is triggered, and the RF_FIELD bit is high.
After these errors, I checked the MB Control Dyn register again, and it was written with the value 0x85, which I believe indicates that the Mailbox was written. Is that correct?
Before suggesting other approaches, I want to clarify that I’ve already tried various methods. For example, I’ve tried sending messages without enabling FTM mode first, and I’ve also tried enabling the High Data Rate flag. Regardless these variations, I keep encountering the same issue.
Could anyone help me understand how to correctly write to the Mailbox using the Android app?
Thank you in advance!
Best Regards.
Solved! Go to Solution.
2024-09-19 03:01 AM
It's a bit more complicated than this.
The mailbox is never cleared or erased.
If you read FF, it is because it is not accessible. This is intrinsic to I2C bus technology: when you do a read and the I2C slave is not answering, you always get value FF because of the pull-up resistors.
You can only read the mailbox if there is a message inside (written from either RF or from I2C).
When you toggle MB_EN bit from 1 to 0 and then 1, you lose the message, and the mailbox is not accessible until you write a new message in it. This is why you read only FF.
Mailbox should be used in a "ping-pong" way: RF (or I2C) write a message -> I2C (or RF) read the message. Then I2C (or RF) can write a new message, and the other side can read it.
Best regards.
2024-09-13 01:16 AM - edited 2024-09-13 01:21 AM
Hi Stefano,
you seem to use the CAh Fast Write Message command. As of today, Android does not support 53 kbit/s mode and therefore cannot support "Fast" commands. I would suggest to try with AAh Write Message command.
Rgds
BT
2024-09-13 03:15 AM
Hi Brian,
thank you for the immediate reply...using this command i was able to write to the mailbox correctly, and i successfully read the message length via the ABh Read Message command. However, I don't understand why the mailbox wasn't updated when i read it via i2c.
What i mean is that if I write to the mailbox using the RF command, should be able to read that same value through I2C with the microcontroller?
Here's what I've done so far:
1. Enabled FTM on the App
2. Used AAh Write Message command to write 0x11 to the first 3 byte of the MB
3. Used the ABh Read Message command, and it confirmed that the message length was '3'
4. Then, I used my custom micro code to readthe mailbox via I2C, but it read the old value that was previously saved in the mailbox (via i2c).
To read the mailbox with I2C, i used a custom function that essentially calls the HAL_I2C_Mem_Read function as follow:
HAL_I2C_Mem_Read(&hi2c1, i2c_addr, (uint8_t)reg, I2C_MEMADD_SIZE_16BIT, &value, 1, HAL_MAX_DELAY);
where:
- i2c_addr = 0xA6
- reg = 0x2008
Do you think this is the correct way to read the mailbox? Why the value I read via I2C is different from what I write via RF?
Ultimately, I'm trying to create a system where messages can be sent via an NFC Reader to the ST25DV tag, and on the microcontroller side, I want to read the message in the mailbox and then trigger actions based on that message. However i don't understand if the MAILBOX can be accessible via I2C and RF at the same time or anyway...can i read the MB via i2c after the RF write but with the presence of the RF field???
Thank you in advance.
Best Regards.
2024-09-17 12:43 AM
Hi Brian!
Have you some tips about my last message?
Thank you in advance for your replies!
Best Regards.
2024-09-17 02:27 AM
Hello,
In order to know who can write into the Mailbox, there is a status register that you can read.
The MB_CTRL_Dyn register (I2C address 2006h, or RF read with Read Dynamic Configuration @0Dh) contains bits that can help you:
- The MB_EN bit must be set to 1 to have the Mailbox functionality
- If the HOST_PUT_MSG bit is set to 1, it means that the I2C has write a message into the mailbox. In this case, I2C can read the mailbox, but can't write it. Same for RF. When RF can read mailbox, this bit is cleared, and Mailbox is free again for RF or for I2C to be written again.
- RF_PUT_MSG bit is the equivalent when RF has written a message into the mailbox. If this bit is set to 1, mailbox can't be written until I2C has read the message.
Another way to free the mailbox is to toggle the MB_EN bit 1->0->1. After this sequence, anyone can write.
You can check those bits in this register to know why you can't read or write from I2C.
Best regards.
2024-09-17 08:35 AM
Hi JL. Lebon!
Thank you for the reply!! I've tried to test the system as you suggest me!
I’ve been running some tests and noticed that the contents of the dynamic registers are set to 0x00 after the I2C write, even though it seemed like it was working.
Here’s the process I follow to write to the mailbox via I2C:
Is this process correct?
However, when I read the dynamic mailbox registers via I2C, they are set to 0x00 as if FTM is disabled. I did make sure to read these registers before disabling FTM in register 0x000D.
So I suspect I’m encountering issues when writing to the mailbox via I2C, and I think this is unrelated to the RF side. All these tests were conducted with the RF field off (I only worked through the u-Controller without using the NFC reader).
Could you provide insights on what might be going wrong or how I can resolve this issue?
Thank you a lot in advance!!
Best Regards
2024-09-17 09:17 AM
Hello,
Actually, the process to write into the mailbox is not correct.
Writing value 0x01 in register 0x000D is not enabling the mailbox. It is just "authorizing" the mailbox activation.
Once 0x000D is set to 1, you must enable the mailbox. This is done by writing register MB_CTRL_Dyn bit 0 (MB_EN) to 1 (address 0x2006) (this can be done without presenting the password).
Then, and only then, you can write into the mailbox (either from RF or from I2C).
You can then disable the mailbox by writing MB_EN=0 in MB_CTRL_Dyn when you are done using the mailbox. Register 0x000D can stay to 0x01 without any consequence.
Hope this is will help you.
Best regards.
2024-09-17 11:49 PM
Hello,
thanks for your response! I tried writing using the procedure you described, but when I write to the mailbox via I2C in this way, I can only write to address 0x2008, while trying to write to the following addresses, the I2C gives me an error.
In this case, I am writing one byte at a time to the various addresses, so I write a byte to 0x2008, then one to 0x2009, then another to 0x200A, and so on. Is this correct, or am I doing something wrong with this procedure as well?
Apologies for the many questions, but I’m struggling to find a way out of these errors!
Best Regards
2024-09-18 12:05 AM
Hello,
Yes, this is expected behavior: write in the mailbox can be done ONLY at the beginning of the mailbox, which is address 0x2008. This is explained in the datasheet chapter "4.5 Fast transfer mode mailbox": "In I2C, mailbox read can start from any address value between 2008h and 2107h. Write mailbox MUST start from
address 2008h to a max of 2107h".
This means that the message MUST be written in one write command. For example, if you want to write a 24 Bytes message, it must be done in one I2C write command of 24 Bytes, starting at address 0x2008. It cannot be done in several I2C write commands starting at addresses different than 0x2008.
The reason is that the ST25DV sets the correct HOST_PUT_MSG bit in the status register when the I2C write command is finished (at the STOP condition). It can't know when the message is complete if the I2C write is made in several distinct commands.
Best regards.
2024-09-18 07:04 AM
Thank you for the precious information!!
I managed to write to the mailbox, but I still have a few doubts:
Once the mailbox is written, do I need to keep the previously enabled settings active (on registers 0x2006 and 0x000D) in order to read it? I noticed that if I set these registers to zero and then re-enable them later for reading, the mailbox is reset to 0xFF for all its values. Is this normal? After writing to the mailbox, should I disable the FTM to work with other functionalities of the chip, or can I leave all the settings enabled? What are the implications of this?
Is it normal that if I write an n-byte message to the mailbox, the MB_LEN_Dyn register indicates that n+1 bytes were written?
Thank you in advance and have a nice day!!
Best Regards