2021-06-29 02:43 AM
I am currently using the v1.6.1 of STM32CubeIDE and a STM32G473 MCU.
I have implemented an I2C bus and have noticed a major bug with the I2C_WaitOnFlagUntilTimeout functions. There is this condition:
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
which is supposed to guarantee that the program doesn't get stuck into the while loop above (while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)), but the tick value stop incrementing as soon as the program enters the function for a reason I don't understand. I have tried to increase the preempt priority of System tick timer (by lowering the value) but it didn't change a thing.
Does anyone know how to fix that?
2021-06-29 06:41 AM
The only reason the ticks would stop increasing is if you're the same or higher priority interrupt, or if interrupts are disabled, or if SysTick is disabled.
2021-06-29 08:40 AM
The thing is I don't even use the I2C bus in interrupt mode. I have no trouble when I don't call the HAL_I2C_Master_Transmit or HAL_I2C_Master_Receive functions, but as soon as I call them I got stuck into an infinite loop in I2C_WaitOnFlagUntilTimeout.
I have tried to low the priority interrupt, without effect, and I didn't disabled SysTick (the HAL_InitTick function returns HAL_OK)
2021-06-29 09:02 AM
2022-01-31 05:33 AM
Could you find a soulution?
I have exactly the same problem. Systick stops and I2C remains in an endless loop waiting that the timeout is reached. That will never happen because Systick is no longer updated.
2022-12-06 04:59 AM
I also have this exact same problem. STM32G0B0. Somewhere in the HAL_I2C_Master_Transmit function, the tick timer interrupt stops firing. In my case HAL_I2C_Master_Transmit returns an error because the I2C device does not acknowledge. So I try and do a short delay and try again, but its stuck in HAL_Delay as the tick value is no longer updating.
2024-07-30 09:18 PM
2024-07-31 06:28 AM
If HAL_GetTick fails to increment, it's generally due to it having lower priority than the thread you're calling it from. There are many posts on this.
If that is not it, post a new topic with sufficient information about the problem.
If you're sure the chip is configured correctly, prove it via screenshots. Likely there is something missing. These chips do what you tell them to do. If something isn't working, there's a reason.