简体   繁体   中英

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 EG:

    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;

Do you have a periodic timer interrupt? In this ISR, you need to call _tx_timer_interrupt. See here for an example for Cortex-M using the SysTick hardware: https://github.com/azure-rtos/threadx/blob/master/ports/cortex_m7/gnu/example_build/tx_initialize_low_level.S#L183-L195

It seems the program did not reach the minimum resolution of the system clock which is by default 10ms, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM