Page 2 of 2

Re: Tickless mode implementation

Posted: Tue Jul 07, 2015 7:21 pm
by hrrr
a small question about the tickless mode....
Does CH_CFG_ST_FREQUENCY have an impact on performance of the system in tickless mode?
In traditional mode increasing CH_CFG_ST_FREQUENCY will increase the number of system interrupts per second. In tickless mode if CH_CFG_ST_FREQUENCY is increased, the system time resolution is better but... does it have any drawbacks? Any reason why a lower CH_CFG_ST_FREQUENCY might be better?

Thanks!

Re: Tickless mode implementation

Posted: Tue Jul 07, 2015 7:28 pm
by Giovanni
Hi,

The drawback is that an higher resolution allows for a shorter time before the time counter wraps back. In case you have a lot of activity with virtual timers you may need to increase the delta parameter in chconf.h. On an F4 I tested up to 4MhZ, probably it could also be increased. 1MhZ is a nice round number to use.

Note that running with too high frequencies does not make sense because the system jitter would become predominant, you would not gain accuracy.

Giovanni

Re: Tickless mode implementation

Posted: Tue Jul 07, 2015 7:52 pm
by hrrr
Ok, thanks!

On a STM32F1 (16 bit timer) using CH_CFG_ST_FREQUENCY 10000 the timer will wrap about every 6.5 seconds, isn't it?
What happens then? I mean...do the virtual timer account for wrapping?

And.. in the same configuration, using the code form the wiki:
--
systime_t time = chTimeNow(); // T0
while (TRUE) {
time += MS2ST(1000); // Next deadline
do_something();
chThdSleepUntil(time);
}
--
would run into porblems after 6.5 seconds, right?
Any suggestion on how to do this reliably for long time with a f1?

Re: Tickless mode implementation

Posted: Tue Jul 07, 2015 10:15 pm
by Giovanni
Absolutely not, the counter is MEANT to wrap, it just means that the largest delay you can specify is 6.5 seconds. An OS that stops working after a finite time would not be nice.

Giovanni

Re: Tickless mode implementation

Posted: Wed Jul 08, 2015 6:40 pm
by hrrr
OK, thanks! I figured it out myself as I had a look at the code...
Sorry for the question

Re: Tickless mode implementation

Posted: Tue Sep 08, 2015 10:58 am
by alexblack
Hi.
Is it possible to implement tickless mode on Timer with DOWN COUNT mode?
Is there any reason why used UP COUNTING mode?

Re: Tickless mode implementation

Posted: Tue Sep 08, 2015 11:45 am
by Giovanni
The counter is used as system time and time is assumed to increase. You may simulate an up-counting counter in the ST driver, of course there is a small overhead.

Giovanni

Re: Tickless mode implementation

Posted: Tue Sep 08, 2015 11:52 am
by alexblack
Thanks - good idea.
I am porting Chibi on EFM32 and want to use Low Energy timer as system because it works in deep sleep mode. Bu it is support only down counting mode. I will try simulate up counter.