Skip to main content
Visitor II
January 10, 2025
Question

HAL library error for I2C mode EEPROM

  • January 10, 2025
  • 2 replies
  • 1549 views

After updating the i2c library to the latest version, I got a write error. After reverting the library to the previous version, the error went away and the location where the error was returned is:

stm32f3xx_hal_i2c.c / I2C_IsErrorOccurred()

Line 7255

It looks like there's probably something wrong with the acknowledge polling process to know when the write cycle is finished.

 

CubeMX V6.13.0

MCU Package STM32F3 Series V1.11.5

STM32F334K6Tx

I2C EEPROM: AT24C16D

 

 

    This topic has been closed for replies.

    2 replies

    Super User
    January 13, 2025

    @JChoi.6 wrote:

    After updating the i2c library to the latest version, I got a write error.


    What error, exactly, did you get?

    Did you check the I2C lines with a logic analyser to see if the hardware is behaving correctly?

    JChoi.6Author
    Visitor II
    January 13, 2025

    The error was returned when calling the HAL_I2C_Mem_Write function consecutively.
    I don't think it's a hardware issue because the problem disappeared when I reverted the library to a previous version.
    If I use a debugger to insert a breakpoint at the beginning of the HAL_I2C_Mem_Write function, the error does not occur.
    Also, the custom I2C EEPROM read/write function is widely used in other products of our company, so it has been sufficiently verified.

     

    Relevant source code is attached.

     

    Thank you for your interest.

    Super User
    January 14, 2025

    @JChoi.6 wrote:

    The error was returned when calling the HAL_I2C_Mem_Write function consecutively..


    Again, what error was it?

    Graduate
    August 15, 2025

    I ran into this today too. When writing to my EEPROM (24LC64T-E/SN) with STM32Cube MCU Package for STM32G4 series v1.6.0 I would fail the second write if I had multiple writes in a row. If I used the debugger I did not fail any of the writes.

    The failures came from I2C_IsErrorOccurred() called inside I2C_WaitOnFlagUntilTimeout(). If I go back to v1.5.0 the I2C_IsErrorOccurred() call isn't in I2C_WaitOnFlagUntilTimeout() and my EEPROM writes are successful.

    Did you ever get a fix for the newest HAL or did you just stay with the old one?