Page 1 of 1

Time measurement units

Posted: Fri Aug 07, 2015 9:02 pm
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.

Re: Time measurement units

Posted: Fri Aug 07, 2015 9:17 pm
by Giovanni

Re: Time measurement units

Posted: Fri Aug 07, 2015 9:40 pm
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).

Re: Time measurement units

Posted: Fri Aug 07, 2015 9:56 pm
by Giovanni
Hi,

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

Giovanni

Re: Time measurement units

Posted: Fri Aug 07, 2015 10:11 pm
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?

Re: Time measurement units

Posted: Sat Aug 08, 2015 6:54 am
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