cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_GetTick() function of STM32F0 driver is blocking SPI interrupts

gaetanbusson
Associate II
Posted on September 15, 2015 at 18:13

Hello,

I have a problem with ''HAL_GetTick()'' that is blocking the SPI interrupt. In my program, I use the ''HAL_SPI_Transmit_IT'' function from STM32F0 HAL driver library to initiate a SPI transmission. After a while, a SPI interrupt occurs and the following functions are called: 0690X00000604sVQAQ.png In the last called function (''HAL_StatusTypeDef SPI_WaitFifoStateUntilTimeout'' function of ''STM32F0xx_HAL_Driver\Src\stm32f0xx_hal_spi.c'' file), the following instruction is blocking my program:

if
((Timeout == 0) || ((HAL_GetTick()-tickstart) >= Timeout))

The tick value is always the same (217) and the program can’t run out of this function until this condition is true. First, I put a breakpoint in function '' GetTick()'' (from '' STM32F0xx_HAL_Driver\Src\stm32f0xx_hal.c'' file but nothing happened: the function was never called. In the

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00122pdf

(STM32F0 driver datasheet), I saw the following note for the ''HAL_InitTick'' function:

Care must be taken if HAL_Delay() is called from a peripheral ISR process, The the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked.

Following this note, I configured all the other interrupts with a lower priority in my STM32CubeMx project:

0690X00000602a0QAA.jpg

Unfortunately, this didn’t change anything.

Does someone have another idea to solve this issue?

Note: the firmware package library I’m currently using is version 1.3.0.

#hal_gettick()-blocking-interrupt
4 REPLIES 4
Posted on September 15, 2015 at 20:44

One approach is not being reliant on counters that are incremented by interrupts. Then priority, and inversions, won't be an issue.

You'd probably want to double check the NVIC Group configurations, and that it's actually got the Preemption and Priority levels you think it has. Look at the registers, and the documentation, don't rely on the tool doing it properly.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Amel NASRI
ST Employee
Posted on September 16, 2015 at 14:56

Hi Gates,

In the CubeMX generated code, I suggest that you comment the following 2 lines at the end of the functionSystemClock_Config:

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

gaetanbusson
Associate II
Posted on September 17, 2015 at 17:31

Hello Mayla,

I tried to comment these two lines but

''HAL_GetTick()''

function still blockin my program.

gaetanbusson
Associate II
Posted on September 17, 2015 at 17:41

There were indeed a problem with the way I was using the driver.

I was trying to send the characters on SPI one by one by calling the

''HAL_SPI_Transmit_IT'' function

from the ''HAL_SPI_TxCpltCallback''.

If I send all my buffer in a row with the

''HAL_SPI_Transmit_IT'' function

, it's working correctly.

Thank you all!