cancel
Showing results for 
Search instead for 
Did you mean: 

ST25DV Mailbox message owner

JonasHSLU
Associate II

Hi,

I am currently working with the X-NUCLEO-NFC08A1 as reader another PCB with a stm32 microcontroller and a ST25DV04K tag. I don't have access to the source code of the board with the tag but i know the used protocol to interact with it.

I got everything running but sometimes it seems as if the HOST_PUT_MSG flag is set before the response is fully written. I poll for the response to be written with something like this:

uint8_t waitCounter = 0;
/* wait for response to be written by tag. */
while (ftmGetMessageOwner() != FTM_MESSAGE_PEER
		&& waitCounter <= FTM_MAX_RESPONSE_WAIT_TIME) {
	platformDelay(1);
	waitCounter++;
}
if(waitCounter == FTM_MAX_RESPONSE_WAIT_TIME){
	platformLog("Tag response timeout.\n");
	return true;
}

But with debugging I found out that sometimes the command sent before is still in the mailbox when the message owner already changed and thus being read instead of the answer.

So my question is: When is the HOST_PUT_MSG bit put? Is it put by the user or does the tag do this automatically? If the tag does it, I suppose that it is put after the I2C wrote the first byte and thus causing my problem.

Kind regards,
Jonas

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions
JL. Lebon
ST Employee

Hello, 

The HOST_PUT_MSG bit is set at the STOP condition of the I2C write into the mailbox.
The I2C can write the message only when RF_PUT_MSG=0 and HOST_PUT_MSG=0.
Then, the MCU writes a message into the mailbox with an I2C write command into the mailbox. At the end of this command, when the I2C STOP occurs and if the I2C command is valid, the HOST_PUT_MSG is set to 1.

The HOST_PUT_MSG is cleared when the RF reader has read the LAST byte of the message that has been written by I2C.

If you found the HOST_PUT_MSG is already set before you have fully written the message, it may be because the RF did not read the previous message and thus did not clear this bit.

Best regards.

View solution in original post

5 REPLIES 5
JL. Lebon
ST Employee

Hello, 

The HOST_PUT_MSG bit is set at the STOP condition of the I2C write into the mailbox.
The I2C can write the message only when RF_PUT_MSG=0 and HOST_PUT_MSG=0.
Then, the MCU writes a message into the mailbox with an I2C write command into the mailbox. At the end of this command, when the I2C STOP occurs and if the I2C command is valid, the HOST_PUT_MSG is set to 1.

The HOST_PUT_MSG is cleared when the RF reader has read the LAST byte of the message that has been written by I2C.

If you found the HOST_PUT_MSG is already set before you have fully written the message, it may be because the RF did not read the previous message and thus did not clear this bit.

Best regards.

JonasHSLU
Associate II

Hi,

Thank you for the quick response. I could resolve the problem now by just waiting until the mailbox is empty by checking if both XXX_PUT_MSG flags are low.

Kind regards,
Jonas

 

Hi @JL. Lebon , is the HOST_PUT_MSG flag set and cleared automatically? If so, can we simply poll the HOST_PUT_MSG flag to check whether a message exists or has been read? Thanks

Hello, 

The HOST_PUT_MSG is set automatically when the MCU writes a message into the mailbox.

It is cleared automatically when:
- mailbox is disabled (MB_EN set to 0)
- VCC is removed
- the mailbox watchdog is triggered (if the watchdog is activated)
- the RF has read the message in mailbox.

So, if you want to know if a message from I2C is present in the mailbox, you can do polling from RF side on this HOST_PUT_MSG bit (polling frequency should not be too high to avoid collision with I2C).

Best regards.

OK