Time measurement units

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
kiv
Posts: 10
Joined: Fri Aug 07, 2015 5:14 pm

Time measurement units

Post by kiv »

How to translate the results of the measurement of time with the functions chTMStartMeasurementX and chTMStopMeasurementX to microseconds?
I use board STM32F4-DISCOVERY, if it is important, and the measurement results do not look like a millisecond, microsecond or system ticks.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Time measurement units

Post by Giovanni »

kiv
Posts: 10
Joined: Fri Aug 07, 2015 5:14 pm

Re: Time measurement units

Post by kiv »



Good. However, this function requires frequency value of the real time counter, but I do not know it. The Doxygen described function halGetCounterFrequency, which will let me know this value, but I use ChibiOS 3.0.0, which not contains function with this name (maybe it was renamed).
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Time measurement units

Post by Giovanni »

Hi,

The information is in the HAL, the RTOS knows nothing about CPU clock. Use STM32_SYSCLK.

Giovanni
kiv
Posts: 10
Joined: Fri Aug 07, 2015 5:14 pm

Re: Time measurement units

Post by kiv »

Thank you. If I use RTC2US(STM32_SYSCLK, ...), it turns to normal (I tested the validity of measurements, measuring the duration chThdSleepMilliseconds(1)). However, so I lost a cross-platform (STM32_SYSCLK defined only for microcontrollers STM32). It's not so important now, but would like to learn for the future. Is there a cross-platform way to convert the measurement results to a microseconds?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Time measurement units

Post by Giovanni »

No, the clock frequency is not available in a portable way at RT level.

You may abstract the information by defining your own macro.

Giovanni
Post Reply