M24SR64 with stm32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-08 03:03 AM
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);
I'm doing something wrong, but I don't know what. If you have some ideas.
Thank you
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-08 06:46 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-08 05:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-08 06:46 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-09 05:21 AM
By checking the datasheet, the last byte of reading operation is NACK, so that's normal.
I've also modify my way to read by adding function "HAL_I2C_IsDeviceReady", now it starts to work better.