cancel
Showing results for 
Search instead for 
Did you mean: 

M24SR64 with stm32

fab04
Associate II

Hi everybody,

I'm working on a nucleo-L476. I'll like to write some data in NFC tag M24SR64 (I'm using a dev board ANT-7-M24SR).

First, I developped functions to read into ndef memoru on ESP32 dev board. It works well (I can read my message with ST app on cell phone).

So now, I try to transfer my code on STM32 platform.

First, I send byte 0x52 to select I2C mode. Then I send bytes to select NFC app and the problem is when I try to read M24SR answer, it always send me a nack answer.

My code :

/* kill RF, select I2C */
	HAL_I2C_Master_Transmit(&hi2c2,(NFC_ADDR_7BIT | WRITE_NFC),selectI2C,sizeof(selectI2C),TIMEOUT_NFC);
	HAL_Delay(1);
 
 
	//select NFC app
	HAL_I2C_Master_Transmit(&hi2c2,(NFC_ADDR_7BIT | WRITE_NFC),selectNFCApp,sizeof(selectNFCApp),TIMEOUT_NFC);
	HAL_Delay(1);
	HAL_I2C_Master_Receive(&hi2c2, (NFC_ADDR_7BIT | READ_NFC), tab_nfc, 5, TIMEOUT_NFC);

0693W00000WHjJAQA1.png0693W00000WHjJUQA1.pngI'm doing something wrong, but I don't know what. If you have some ideas.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee

Hi @fab04​,

Another point to take into account is that the NACK could inform you that the I²C command has not finished to be processed. You could poll the I²C after each command by sending device address and waiting for an ACK before sending the next command. See DataSheet section 7 I²C device operation for more information.

You could use also the GPO for that instead of polling (not for GetI2Csession and KillRFsession).

Kind Regards.

View solution in original post

3 REPLIES 3
Ulysses HERNIOSUS
ST Employee

Hi,

not an expert m24sr but I presume that analysis will be easier if you set I2C decoder to hex mode and possibly share the trace itself.

Best Regards, Ulysses

Rene Lenerve
ST Employee

Hi @fab04​,

Another point to take into account is that the NACK could inform you that the I²C command has not finished to be processed. You could poll the I²C after each command by sending device address and waiting for an ACK before sending the next command. See DataSheet section 7 I²C device operation for more information.

You could use also the GPO for that instead of polling (not for GetI2Csession and KillRFsession).

Kind Regards.

fab04
Associate II

By checking the datasheet, the last byte of reading operation is NACK, so that's normal.

0693W00000WHtVkQAL.pngI've also modify my way to read by adding function "HAL_I2C_IsDeviceReady", now it starts to work better.