Skip to main content
Associate III
September 13, 2024
Solved

Write on Mailbox via Android APP (ST25DV64KC)

  • September 13, 2024
  • 12 replies
  • 3606 views

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:

  1. First, I enabled the Mailbox in the "Mailbox Management" menu.
  2. Then, I verified that FTM mode was enabled by checking the MB Control Dyn register in the "Dyn Register Management" menu (it was set to 0x01).

Next, I sent the following message through the "Send Custom Command" menu using this configuration:

  • Option Flag: Disabled
  • Addressed mode: Enabled
  • Select mode: Disabled
  • High Data Rate: Disabled
  • Format Extension: Disabled
  • CMD_CODE = 0xCA (MBFastWriteMsg)
  • Manufacturer = 0x02
  • DATA = 0x0311223344
  • UID = 0B D2 15 76 66 51 02 E0

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:

  1. "Tag not in field"
  2. "CMD_ERROR"

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.

This topic has been closed for replies.
Best answer by JL. Lebon

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.

12 replies

Brian TIDAL
ST Technical Moderator
September 13, 2024

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate III
September 17, 2024

Hi Brian!

Have you some tips about my last message?

Thank you in advance for your replies!

 

Best Regards.

 

Associate III
September 17, 2024

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:

  1. Present the password.
  2. Enable FTM mode by writing the value 0x01 to register 0x000D.
  3. Write to the mailbox via I2C starting from address 0x2008.
  4. Disable FTM mode by writing 0x00 to register 0x000D.

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

JL. Lebon
ST Employee
September 17, 2024

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.

Associate III
September 18, 2024

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

JL. Lebon
ST Employee
September 18, 2024

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.