Skip to main content
Explorer
September 13, 2024
Solved

Write on Mailbox via Android APP (ST25DV64KC)

  • September 13, 2024
  • 2 replies
  • 3484 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.

    2 replies

    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

    Explorer
    September 13, 2024

    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.

    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.

    Explorer
    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

    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.