Skip to main content
Visitor II
January 27, 2020
Question

HAL_Delay never exits even after increasing the priority of Systick to highest priority.

  • January 27, 2020
  • 3 replies
  • 1169 views

Hi all,

I am working with the Nucleo-F446ZE board.

I generated a project with CubeMx .

At this point the project is running fine with UART interrupts and data.

I debug the project and all is working.

I need to use a delay function in my project. SO I have used HAL_Delay(20); for example.

But it never exits from that function. Debugging at it came to know it stuck in below while loop.

 while((HAL_GetTick() - tickstart) < wait)

 {

 }

Any help?I am using the Delay function inside UART ISR. Please help.

    This topic has been closed for replies.

    3 replies

    Super User
    January 27, 2020

    Using HAL_Delay in an ISR is rarely a good idea. Are you sure that the USART ISR prio is lower than SysTick?

    TH.16.336Author
    Visitor II
    January 28, 2020

    Looks like both interrupts priority was same.

    This was causing the issue. Thanks for the reply. Now it's working.

    Super User
    January 28, 2020

    Possibilities:

    1) SysTick interrupt isnt set up or enabled

    2) interrupts are disabled

    3) priority of systick is less or equal to that of the uart. Note that priority of 0 is highest priority.

    4) interrupts cannot preempt each other. Check priority grouping setting.

    TH.16.336Author
    Visitor II
    January 28, 2020

    Looks like both interrupts priority was same as 0.

    This was causing the issue. Thanks for the reply. Now it's working.

    Visitor II
    January 28, 2020

    check your interrupt settings