2015-09-15 09:13 AM
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: 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:
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
2015-09-15 11:44 AM
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.2015-09-16 05:56 AM
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.
2015-09-17 08:31 AM
Hello Mayla,
I tried to comment these two lines but''HAL_GetTick()''
function still blockin my program.2015-09-17 08:41 AM
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!