Hello,
I need in my program based on ChibiOS time measurement with microsecond accuracy. It will be used as the system clock for event timestamps and for time synchronization of some tasks. Also I need to be able to set the system time. What is the best way to do this on ChibiOS? I looked throuhgt the docs but i have not found tools to do this. Please advice how to do this.
Best regards,
Franek
STM32F103VET6 Timestamps and time measurement
Moderator: RoccoMarco
-
franek.bmw
- Posts: 57
- Joined: Thu Mar 13, 2014 11:15 am
- Has thanked: 2 times
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F103VET6 Timestamps and time measurement
In 2.6 there is a "Time Measurement" driver in the HAL. In 3.0 it is part of the RT kernel. See the time measurement section in the documentation.
http://chibios.sourceforge.net/docs3/rt ... ement.html
Giovanni
http://chibios.sourceforge.net/docs3/rt ... ement.html
Giovanni
-
franek.bmw
- Posts: 57
- Joined: Thu Mar 13, 2014 11:15 am
- Has thanked: 2 times
Re: STM32F103VET6 Timestamps and time measurement
I think this is not exactly what I mean. I need something like RTC with us accuracy with some function like gettime and settime. Any ideas?
Second question is how to read the current value of the timer using GPT?
Franek
Second question is how to read the current value of the timer using GPT?
Franek
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F103VET6 Timestamps and time measurement
You can use the system time, in 3.0 it is possible to set it to 1MHz (or even higher) on F4 devices when the tickless mode is activated.
Giovanni
Giovanni
-
franek.bmw
- Posts: 57
- Joined: Thu Mar 13, 2014 11:15 am
- Has thanked: 2 times
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32F103VET6 Timestamps and time measurement
In that case:
However this only works on M3 and M4 targets, not M0. This API is no more present in 3.0, replaced by the mechanism I mentioned before.
Giovanni
Code: Select all
/**
* @name Macro Functions
* @{
*/
/**
* @brief Returns the current value of the system free running counter.
* @note This is an optional service that could not be implemented in
* all HAL implementations.
* @note This function can be called from any context.
*
* @return The value of the system free running counter of
* type halrtcnt_t.
*
* @special
*/
#define halGetCounterValue() hal_lld_get_counter_value()
/**
* @brief Realtime counter frequency.
* @note This is an optional service that could not be implemented in
* all HAL implementations.
* @note This function can be called from any context.
*
* @return The realtime counter frequency of type halclock_t.
*
* @special
*/
#define halGetCounterFrequency() hal_lld_get_counter_frequency()
/** @} */
However this only works on M3 and M4 targets, not M0. This API is no more present in 3.0, replaced by the mechanism I mentioned before.
Giovanni