cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in stm32f3xx_hal_i2c.c

fal.sch
Associate II

CubeIDE version 1.4.1

STM32Cube FW_F3 V1.11.0

I had the problem, that my I2C communication (alternating rx/tx on slave) works on the first rx/tx cycle but fails on the second tx.

The transmission skips the first byte and thus sending n-1 bytes. I found out that, after calling I2C_ITSlaveCplt() on line 4744, the execution of the function continues and decrements the XferCount on line 4802.

I fixed the driver as follows (original line 4740-4745):

/* Check if STOPF is set */
  if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_STOPF) != RESET) && (I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_STOPI) != RESET))
  {
    /* Call I2C Slave complete process */
    I2C_ITSlaveCplt(hi2c, tmpITFlags);
  }
/* Check if STOPF is set */
  if ((I2C_CHECK_FLAG(tmpITFlags, I2C_FLAG_STOPF) != RESET) && (I2C_CHECK_IT_SOURCE(ITSources, I2C_IT_STOPI) != RESET))
  {
    /* Call I2C Slave complete process */
    I2C_ITSlaveCplt(hi2c, tmpITFlags);
    
    // BEGIN BUG FIX
    __HAL_UNLOCK(hi2c);
 
    return HAL_OK;
    // END BUG FIX
  }

This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
fal.sch
Associate II

Alternatively the following if-statement could be changed to an else-if-statement which is similar to the previous working driver version.

Amel NASRI
ST Employee

Hi @fal.sch​ ,

This issue is reported to our development team for farther check and analysis in order to apply the adequate solution.

Thanks for highlighting it.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.