Skip to main content
DextroLaev
Associate II
July 20, 2021
Solved

Can't we use HAL_Delay() inside an Interrupt Service Routine ?

I am new to stm32, I have a stm32F407VG discovery board. I tried to implement an interrupt using the user button and added HAL_Delay() inside the interrupt function. After I press the Button the Interrupt execute but it got stuck there, it is not coming back to main(). What should I do to handle this ?

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
July 20, 2021

Problematic in ISR and call-backs that HAL makes from same interrupt context.

Figure out a better way of coming back later to follow up.

Or change the SysTick to have the highest priority, at its own preemption level, keeping it very short.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

3 replies

TDK
July 20, 2021

Yes, but it's not best practice.

You need to ensure the SysTick interrupt still fires, so SysTick must be at a higher preemption priority (numerically lower) than the interrupt you're currently in.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
July 20, 2021

Problematic in ISR and call-backs that HAL makes from same interrupt context.

Figure out a better way of coming back later to follow up.

Or change the SysTick to have the highest priority, at its own preemption level, keeping it very short.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
DextroLaev
Associate II
July 21, 2021

Problem solved by reducing the interrupt priority.