High-Resolution Timer proposal

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
bobc
Posts: 10
Joined: Wed Oct 17, 2012 1:36 pm

Re: High-Resolution Timer proposal

Post by bobc »

I apologize if my previous message didn't make sense, I am still getting to grips with Chibios and had misunderstood the documentation. The GPT seems to do exactly what I want, I had the impression the GPT only works with system ticks (CH_FREQUENCY) but this seems not the case.

I am still unsure of the function/use of the other timer/virtual timer functions, but I think I am good with the GPT driver.

Personally I have found there is too much overhead handling timer queues with resolution much below 1ms, so that is a route I would not go down.
skute
Posts: 64
Joined: Wed Aug 29, 2012 10:17 pm

Re: High-Resolution Timer proposal

Post by skute »

Giovanni wrote:Wouldn't pausing decrease the precision in time of events?

Giovanni



Yes, pausing the timer will decrease the precision in time of events. The timer is only paused to atomically read the amount of time that has currently elapsed since the it was started, and then take action based on that. For example, when starting a new timer; if there is a timer currently running, to decide whether the new timer will expire before or after the running timer, we pause the timer. There are also situations in which you need to know if the timer interrupt is pending and you have blocked it because of a call to chSysLock(). To accurately/atomically detect this situation, you need to pause the timer.

This precision loss can be accounted for in the low-level driver if it were to timestamp when pausing or when the isr triggers then using this information to subtract the required microseconds when starting the next timer.
billr
Posts: 12
Joined: Sun Feb 24, 2013 8:36 pm

Re: High-Resolution Timer proposal

Post by billr »

I need a delay with 10 us resolution and came across this post. Has any further work been done on a high resolution timer?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: High-Resolution Timer proposal

Post by Giovanni »

You can already do that: halPolledDelay() or, alternatively, gptPolledDelay().

High resolution timers are being considered for ChibiOS 3.0, too much of a change for the current major version.

Giovanni
billr
Posts: 12
Joined: Sun Feb 24, 2013 8:36 pm

Re: High-Resolution Timer proposal

Post by billr »

Thanks, I'll check out those functions. There's so much capability in ChibiOS, it's hard to know it all.
Post Reply