High resolution event scheduling in tickless-mode?

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.
Post Reply
User avatar
Erikk
Posts: 10
Joined: Wed Jan 22, 2014 1:26 pm
Been thanked: 1 time

High resolution event scheduling in tickless-mode?

Post 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
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: High resolution event scheduling in tickless-mode?

Post 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
User avatar
Erikk
Posts: 10
Joined: Wed Jan 22, 2014 1:26 pm
Been thanked: 1 time

Re: High resolution event scheduling in tickless-mode?

Post 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!
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: High resolution event scheduling in tickless-mode?

Post 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
User avatar
russian
Posts: 368
Joined: Mon Oct 29, 2012 3:17 am
Has thanked: 16 times
Been thanked: 14 times

Re: High resolution event scheduling in tickless-mode?

Post 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.
Post Reply