Search code examples
timethreadxazure-rtos

tx_time_get() always returns 0 in threadx module manager


I am trying to calculate the time ticks, however tx_time_get() always returns 0 wherever I put it in modules or module manager of ThreadX E.G:

    ULONG start_time, current_time=0, cycle_time=0;
    start_time= tx_time_get();
    current_time=tx_time_get();
    cycle_time= current_time-start_time;

Solution

  • It seems the program did not reach the minimum resolution of the system clock which is by default 10 MS, so I need to decrease the resolution by changing TX_TIMER_TICKS_PER_SECOND in order to calculate the time spent on a certain block. However, it will decrease the performance.

    Ref