Skip to main content
Kamil Kisiel
Associate III
December 1, 2017
Question

LL_Init1msTick disables SysTick interrupt

  • December 1, 2017
  • 5 replies
  • 3019 views
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.

    This topic has been closed for replies.

    5 replies

    Nesrine M_O
    Associate
    December 4, 2017
    Posted on December 04, 2017 at 16:11

    Hi

    Kisiel.Kamil

    ,

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

    -Nesrine-

    Kamil Kisiel
    Associate III
    December 4, 2017
    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.

    Bogdan Golab
    Lead
    September 8, 2019

    You need LL_SYSTICK_EnableIT();

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

    Taylor.Sean
    Associate III
    December 11, 2018

    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
    Visitor II
    August 1, 2019

    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.