Skip to main content
Lukasz Przenioslo
Associate III
October 6, 2015
Question

HAL FreeRTOS change time base

  • October 6, 2015
  • 4 replies
  • 806 views
Posted on October 06, 2015 at 11:28

Hello there,

I am using HAL library with FreeRTOS middleware. The minimum delay I can use for the osDelay() function seems to be 1 ms. I would like to turn on task periodically every 10 or 100 ns. Is that even possible? I would apreciate all help.
    This topic has been closed for replies.

    4 replies

    qwer.asdf
    Senior
    October 6, 2015
    Posted on October 06, 2015 at 13:54

    You should use one of the general purpose timers for that task. It will generate an interrupt every X ns, you then do what you want in the interrupt handler but you must be fast enough to complete your task in less than X ns.

    Lukasz Przenioslo
    Associate III
    October 6, 2015
    Posted on October 06, 2015 at 13:59

    Yes I understand the concept. The systick timer is responsible for the bit ticking of osDelay. But even though I change its timebase:

    HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/100);

    The framework manages and adjusts, as the osDelay takes ms not ns and is recalculated. Thats why I am wondering either there is a way around it?
    qwer.asdf
    Senior
    October 6, 2015
    Posted on October 06, 2015 at 14:06

    FreeRTOS requires your SysTick to be exactly 1ms to work correctly. Just use another timer, leave the SysTick timer to the OS.

    Lukasz Przenioslo
    Associate III
    October 6, 2015
    Posted on October 06, 2015 at 14:41

    I understand, thank you.