Hey,
I am trying to measure the time a portion of code needs on my STM32F0-Discovery with ms resolution.
First I was doing well when using chTimeNow() twice and doing the difference, but since I get same values too often in a row I am not trusting those results anymore. Also I used the difference as result already in [ms]; is this correct?
Secondly I wanted to use TimeMeasurmentUnit and found this seems not be supported by STM32F0?!
Can anyone give me an advice, please?
THX
Regards from Germany
Time Measurement Unit on STM32F0
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time Measurement Unit on STM32F0
Hi,
The time measurement unit is not supported on the M0 because it lacks the realtime counter present on the M3 and M4. A new mechanism will be present in ChibiOS 3.0 but it cannot be backported to 2.6.
You may try to increase the system time resolution CH_FREQUENCY, it should be able to handle up to 5000/10000 and continue to use chTimeNow().
Giovanni
The time measurement unit is not supported on the M0 because it lacks the realtime counter present on the M3 and M4. A new mechanism will be present in ChibiOS 3.0 but it cannot be backported to 2.6.
You may try to increase the system time resolution CH_FREQUENCY, it should be able to handle up to 5000/10000 and continue to use chTimeNow().
Giovanni
Re: Time Measurement Unit on STM32F0
Hi Giovanni,
thanks for the quick info. My setting of CH_FREQUENCY is 1000 at the moment. What does this actually say? Doesn't it mean 1ms resolution of the chibiOS implemented system timer? So can't I use the output value of chTimeNow() directly as the system run time in [ms] then?
Cheers
thanks for the quick info. My setting of CH_FREQUENCY is 1000 at the moment. What does this actually say? Doesn't it mean 1ms resolution of the chibiOS implemented system timer? So can't I use the output value of chTimeNow() directly as the system run time in [ms] then?
Cheers
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time Measurement Unit on STM32F0
Hi,
Correct, chTimeNow() does not return milliseconds and is not meant to, it returns time in system tick time units, you can convert that to milliseconds using ST2MS() which compensates for timer resolution.
Giovanni
Correct, chTimeNow() does not return milliseconds and is not meant to, it returns time in system tick time units, you can convert that to milliseconds using ST2MS() which compensates for timer resolution.
Giovanni
Re: Time Measurement Unit on STM32F0
Sorry, Giovanni, compiler can't find ST2MS whereas I know MS2ST is defined in virtual timer code. Do I have to include or activate some thing else?
Re: Time Measurement Unit on STM32F0
Well, I found a implementation on github:
Code: Select all
define ST2MS(st) ((st / CH_FREQUENCY) * 1000L)- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time Measurement Unit on STM32F0
This is really odd, I was sure the implementation was already provided, I'll add those macros in 2.6.2.
Giovanni
Giovanni
Re: Time Measurement Unit on STM32F0
Actually this macro doesn't even get me what I want since there is integer division involved...
I only get 0 or i*1000ms out of this.
I only get 0 or i*1000ms out of this.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time Measurement Unit on STM32F0
I meant correct macros
look at the existing ones in chvt.h, the interger arithmetic is considered.
Giovanni
Giovanni