Skip to main content
Graduate
March 6, 2024
Solved

SysTick and FREE Rtos

  • March 6, 2024
  • 2 replies
  • 2116 views

Hi to everybody.

I'm using H5 and FREE RTOS. I'm porting a project from M3 , than M4 now to H5. I used LL for all the periferals, but moving to HAL isn't a probelm (... but I prefer  LL!).

On M3 and M4 I used a timers to "serve" the RTOS scheduler, then SysTick for a simple delay (yes, also on a task!). E.G. when I need few milliseconds between toggling a output while driving the display.

With H5 I can't use something like "LL_mDelay(100);" because it stuck.

How I can enable systick with H5 (voa MSX CUBE) the LL_mDelay (or HAL_Delay) to measure a time, or simply get a systick?

Thanks in advance.

 

    This topic has been closed for replies.
    Best answer by Pavel A.

    @TheRaprus Haven't you also find the note, "When a RTOS is used, it is recommended to avoid using blocking delay and use rather osDelay"? It is quite prominent there.

    2 replies

    Graduate II
    March 6, 2024

    In CubeMX configure the SYS Timebase Source to TIM1 (or some other timer (not SysTick!) you don't need for your application).  Leave SysTick for FreeRTOS to use (exclusively).

    TheRaprusAuthor
    Graduate
    March 7, 2024

    Hi Devid.

    Thanks for the answer.

    Using a timer (in my case Tim5) is what I did, and also the CubeMX remeber all the time to switch fron SysTick.

    WHat happe is that the  HAL_Delay(x) work fine, but the LL_mDelay(x) stuck. Entering in the source of the LL (file stm32h5xx_ll_utils.c) I found this:

     @note When a RTOS is used, it is recommended to avoid using blocking delay and use rather osDelay service.
    void LL_mDelay(uint32_t Delay){
     __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */
     uint32_t tmpDelay = Delay;
     /* Add this code to indicate that local variable is not used */
     ((void)tmp);
     /* Add a period to guaranty minimum wait */
     if (tmpDelay < LL_MAX_DELAY)
     tmpDelay++;
     while (tmpDelay != 0U) {
     if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) 
     tmpDelay--;
     }
    }

    The "SysTick->CTRL" is 0 and never change, so it stuck! I'll check it again to see what happen without RTOS and in HAL_Delay. I can change LL_mDelay to HAL_Delay but it'a pity!

    Pavel A.Answer
    Super User
    March 7, 2024

    @TheRaprus Haven't you also find the note, "When a RTOS is used, it is recommended to avoid using blocking delay and use rather osDelay"? It is quite prominent there.

    TheRaprusAuthor
    Graduate
    March 7, 2024

    Hi Pavel.

    I copy the intentionally the note (and remove the others), because I know it! But as I wrote in the beginning. I used it on M3 and M4. And they work!