cancel
Showing results for 
Search instead for 
Did you mean: 

LL_Init1msTick disables SysTick interrupt

Kamil Kisiel
Associate III
Posted on December 01, 2017 at 21:45

I recently generated code for a project using STM32CubeMX which used mixed LL and HAL drivers (HAL only for USB). At the beginning of main the generated code calls HAL_Init, which is all well and good, but then later calls SystemClock_Config which in turn calls LL_Init1msTick. The problem is that LL_Init1msTick (which then calls LL_InitTick) overwrites the SysTick->CTRL register with the value SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; Notably absent is the SysTick_CTRL_TICKINT_Msk flag which is required for the SysTick interrupt to be called. This causes any subsequent HAL calls to fail because most of the use HAL_Delay or HAL_GetTick in some way, and now the tick is no longer being enabled.

Seems like a pretty nasty bug for anyone trying to mix HAL and LL drivers.

5 REPLIES 5
Nesrine M_O
Lead II
Posted on December 04, 2017 at 16:11

Hi

Kisiel.Kamil

,

Thank you for sharing this issue.It is reported internally for check.

-Nesrine-

Posted on December 04, 2017 at 18:45

Thanks Nesrine,

I guess I should specify that this was with the STM32F4 HAL, but I just checked the most recent F0 and F7 HAL and they seem to have the same problem.

Taylor.Sean
Associate II

I can confirm the same problem with STM32L4 HAL LL. I was scratching my head about why the SysTick handler was not being called until I looked in the CTRL register and found it disabled.

DPaul.13
Associate

If you've got HAL libraries available something like this seems to work:

 HAL_SuspendTick();

 LL_Init1msTick( 8000000 );

 HAL_ResumeTick();

I'm working with the STM32F030CC and dynamically changing system clock source between 48 MHz PLL and 8 MHz HSI. This gets SysTick back tracking. But on the other hand, when I try to flip back later in the code, something heads south. Don't know yet if that's related or a new mystery.

You need LL_SYSTICK_EnableIT();

because for LL the IT is not enabled (HAL enables it automatically)