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

How to change FreeRTOS initial tick count ?

Hello,

I am using the NRF52840 with FreeRTOS and I would like to start the FreeRTOS tick count at a high value for testing purpose.

I have modified the  configINITIAL_TICK_COUNT value in the FreeRTOS.h file with a high value : 0xffffffff  - 0x1e000 = 0xfffe1fff

(0xffffffff correspond to the maximal tick count, TickType_t beeing a uint32_t value)

(0x1e000 = 2*60*1024 is for 2 minuts, configTICK_TATE_HZ value beeing at 1024)

It should start FreeRTOS tick count at 0xfffe1fff and go back to the zero value after 2 minuts (acctually this is what I want to test), but I have an unexpected result when I use the xTaskGetTickCount() function to see the tick count value (now is the value returned by the xTaskGetTickCount function) :

(FreeTROS.h) #define configINITIAL_TICK_COUNT 0

(LOG) now=4000 (4000 = 3*1024 = 3 sec)

--

(FreeTROS.h) #define configINITIAL_TICK_COUNT 0xfffe1fff

now=3119

I wonld expect the now value to be mutch higer than 4000 (about 0xfffe1fff = 4294844415)

Does anyone know where my problem comes frone ?

Thanks a lot,

Clément

Parents
  • Thank you for your answer,

    I am printing these logs in a thread called after the vTaskStartScheduler(). I was logging my 32bits TickType_t with a %d instead of a %ld, it may resolve a part of the probleme but I am still in trouble:

    I am trying to reproduce this error in a simple environment : I am using the NRF52840 dev board and I took the ble_app_hrs_freertos example code from the nrf SDK. I just added my log in a periodically called function:

    static void heart_rate_meas_timeout_handler(TimerHandle_t xTimer)
    {
    TickType_t val;
    val = xTaskGetTickCount();
    NRF_LOG_INFO("Tick Count : %ld", val);

    And I changed the FreeRTOS.h file from the SDK :

    #define configINITIAL_TICK_COUNT 0xff000000

    I am using CoolTerm (mac) to print my logs and I have the folowing result:

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1289

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1290

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (196).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (197).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (198).[0m

    <info> app: Tick Count : 1291

    .[1;31mLogs dropped (197).[0m

    <info> app: Tick Count : 1292

    .[1;31mLogs dropped (197).[0m

    <info> app: Tick Count : 1911

    <info> app: Tick Count : 2784

    <info> app: Tick Count : 3796

    <info> app: Tick Count : 4793

    <info> app: Tick Count : 5784

    It seems that the tick count restarts after a while. Do you have an idea of what is happening ?

  • This is because the initial value of RTC->COUNTER is different from configINITIAL_TICK_COUNT.

    can be handled as follows:

Reply Children
No Data
Related