2022-08-02 02:30 AM
2022-08-02 02:41 AM
Hi folks !
I'm working with a STM32F302 MCU and I'm currently getting trouble with I2C to store data on 24LC512 EEPROM.
I can store and recall data once, it works fine. But when I call the HAL_I2C_Mem_Write function twice or more it only work for the first data and not for the others. When I scope this, I've got all the 4 bytes ( 1 control byte + 2 byte for the memory address + data) of the first transmission and I have only 1byte + 2 more bits for the next transmission and it stops...
Moreover, when I run the program in debug mode there no problem, all data are well stored...
What a weird behaviour ! Anyone has an idea ?
PS : the HAL_I2C_Mem_Read() function works well even with multiple queued calls.
Thanks
Leo B.
2022-08-02 02:59 AM
Perhaps there are expectations on you waiting or checking status to ensure the write operation has completed?
2022-08-02 03:14 AM
.
2022-08-02 03:30 AM
I already tried adding a delay between transmissions and checking the i2c busy flag but it did not fix the problem.
And how you you explain the second transmission start and stop midway ?
2022-08-02 04:55 AM
Ok ! The datasheet says to wait at least 5ms between two transmissions, (which is a lot). Here was the problem !