cancel
Showing results for 
Search instead for 
Did you mean: 

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

DextroLaev
Associate II

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
TDK
Guru

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".

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
Up vote any posts that you find helpful, it shows what's working..
DextroLaev
Associate II

Problem solved by reducing the interrupt priority.