Page 1 of 1

High resolution event scheduling in tickless-mode?

Posted: Tue Feb 04, 2014 11:22 am
by Erikk
Will the tickless mode in Chibios 3.0 enable virtual timers and delays/etc with 1usec resolution?

Like configuring CH_CFG_ST_FREQUENCY to 1000000 ?

I have a STM32F4-project where i want to schedule events with down to 1-2usec resolution.

It could be done with hardware timers, OutputCompare and some sort of minheap Sorting scheduler, but it would be really nice if one could do it directly in chibios.

Any other suggestions on how to schedule events with high resolution?

Thanks
Erik

Re: High resolution event scheduling in tickless-mode?

Posted: Tue Feb 04, 2014 11:27 am
by Giovanni
Hi,

You should not go with such low values, there are limits. On the F4 a safe resolution should be 10-20uS, higher resolutions are being investigated.

Note that even with a 1uS resolution you would get a very high jitter with such low values.

If you need accurate timings you have to use an HW timer AND have it generate a fast interrupt in order to reduce jitter.

Giovanni

Re: High resolution event scheduling in tickless-mode?

Posted: Tue Feb 04, 2014 11:56 am
by Erikk
Hi and thanks for the super-quick reply!

Is this a proper way to deal with something like this?
I´ll also have to check how close together two events can be scheduled without the next one getting dropped.


Image



Thanks again!

Re: High resolution event scheduling in tickless-mode?

Posted: Tue Feb 04, 2014 1:50 pm
by Giovanni
Keep in mind that you cannot invoke kernel APIs from a fast IRQ handler, you would need your own events handling (basically a mask of flags).

You can use PENDSV in order to delegate to a lower priority ISR calls to the kernel.

You could use"cpsie i" and "cpsid i" can be used for mutual exclusion between the low priority and high priority worlds (keep it short of course, that code is your jitter).

Giovanni

Re: High resolution event scheduling in tickless-mode?

Posted: Fri May 02, 2014 5:24 pm
by russian
Erik, did you end up implementing any kind of minheap Sorting scheduler?

First of all, I wonder if there is a non-head tree implementation one can use for that. I am playing with http://troydhanson.github.io/uthash/utlist.html but that's O(n^2) for iteration with removal, so that would only work for really small n.