Skip to main content
Visitor II
July 20, 2021
Solved

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

  • July 20, 2021
  • 3 replies
  • 934 views

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.
    Best answer by Tesla DeLorean

    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.

    3 replies

    Super User
    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.

    Graduate II
    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.

    Visitor II
    July 21, 2021

    Problem solved by reducing the interrupt priority.