This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS changes for better RTOS timer accuracy

Hi,

I have made some changes with how we update tick timer inside FreeRTOS and the results are promising . The improvement is

  1. RTOS tick will auto correct if masked for more than one tick. BLE activity will not affect the RTOS tick accuracy. No ticks will be lost.
  2. better RTOS timers resolution (max deviation noticed with BLE traffic is 2%).
  3. TicklessIDLE wakeup tick correction is simplified using RTC overflow feature
  4. More stable BLE connections due to increased efficiency of RTOS timers.

I have tested this for few hours but I need you guys to give feedback on how this improves your setup.

Parents
  • NOTE. tested on SDK12.x only (might work with other SDKs, but i am not sure)

    apply this patch in SDK\external\freertos folder

    No_Ticks_lost.patch

    Discussion for a clarification for vTaskStepTick is started here
    Update: The change in task.c::vTaskStepTick is now confirmed by FreeRTOS team to be safe and required in our case

    EDIT: 19th May 2017

    DO NOT USE THIS PATCH IN YOUR NEW DESIGNS. better patch available in here

  • SDK 13.0.0

    if (configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG == 0)
    {
        /* check FreeRTOSConfig.h file for more details on configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG */
        TickType_t diff;
        diff = ((m_tick_overflow_count << portNRF_RTC_BITWIDTH) + systick_counter) - xTaskGetTickCount();
    
        while((diff--) > 0)
        {
            switch_req |= xTaskIncrementTick();
        }
    }
    else
    {
        switch_req = xTaskIncrementTick();
    }
    
    /* Increment the RTOS tick as usual which checks if there is a need for rescheduling */
    if ( switch_req != pdFALSE )
    { 
       	 ...
    }
    
Reply
  • SDK 13.0.0

    if (configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG == 0)
    {
        /* check FreeRTOSConfig.h file for more details on configUSE_DISABLE_TICK_AUTO_CORRECTION_DEBUG */
        TickType_t diff;
        diff = ((m_tick_overflow_count << portNRF_RTC_BITWIDTH) + systick_counter) - xTaskGetTickCount();
    
        while((diff--) > 0)
        {
            switch_req |= xTaskIncrementTick();
        }
    }
    else
    {
        switch_req = xTaskIncrementTick();
    }
    
    /* Increment the RTOS tick as usual which checks if there is a need for rescheduling */
    if ( switch_req != pdFALSE )
    { 
       	 ...
    }
    
Children
No Data
Related