cancel
Showing results for 
Search instead for 
Did you mean: 

CPU hangs when calling I2C_WaitOnFlagUntilTimeout ().

ausera uirwaij
Associate III

CPU hangs when calling I2C_WaitOnFlagUntilTimeout because I2C DMA interrupt handler has higher priority than system handle, so that tickcount cannot hit the Timeout. How can I resolve this trouble without consuming too much CPU ? I saw some topics about STM32 I2C bug they reject that make I2C interrupted by others, so I wonder to know is it really okay when I set I2C RxTx interrupt with lower priority than system handle? I has freertos in my project.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

If you use HAL functions that make use of HAL_GetTick (such as HAL_I2C_* functions) from within an interrupt context, you need to ensure the system tick interrupt is a higher priority than the context from which you're calling.

Better yet, don't use blocking functions in interrupts. Set flags instead and handle them in a non-interrupt thread.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
Piranha
Chief II

> system handle

What is that? Looks like some random "smart" words sticked together without meaning.

> because I2C DMA interrupt handler has higher priority than system handle, so that tickcount cannot hit the Timeout

So you know the problem, but... Just want to talk about it? Adjust the priorities as necessary!

TDK
Guru

If you use HAL functions that make use of HAL_GetTick (such as HAL_I2C_* functions) from within an interrupt context, you need to ensure the system tick interrupt is a higher priority than the context from which you're calling.

Better yet, don't use blocking functions in interrupts. Set flags instead and handle them in a non-interrupt thread.

If you feel a post has answered your question, please click "Accept as Solution".