Skip to main content
Visitor II
August 17, 2020
Question

Bug in stm32f3xx_hal_i2c.c

  • August 17, 2020
  • 2 replies
  • 990 views

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 topic has been closed for replies.

    2 replies

    fal.schAuthor
    Visitor II
    August 17, 2020

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

    Technical Moderator
    August 17, 2020

    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