AVR tickless mode Topic is solved

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

Posts: 2
Joined: Mon Nov 05, 2018 10:27 am
Has thanked: 2 times

AVR tickless mode

Postby _Desh_ » Mon Nov 05, 2018 11:08 am

I study ChibiOS and need some help.

When I tested tickless mode from Arduino Uno demo example, I found that prescaler value is hard-coded to 1024 (hal_st_lld.c) and tick frequency is set to 15625 (obviously F_CLK/1024). So I have a question:

- what is the basic principle on how to calculate prescaler in tickless mode if I want to set a 1000 Hz (1 ms) tick? How do we consider a hardware timer resolution in this matter? Why do we need to set tick frequency to the higher value than in the periodic tick mode?

User avatar
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times

Re: AVR tickless mode  Topic is solved

Postby Giovanni » Mon Nov 05, 2018 9:34 pm


You can have the same tick frequency in tick and tickless mode, it does not need to be different.


Posts: 2
Joined: Mon Nov 05, 2018 10:27 am
Has thanked: 2 times

Re: AVR tickless mode

Postby _Desh_ » Tue Nov 06, 2018 5:27 pm

We can't set tick frequency to 1000 in this case because AVR timer1 is capable of counting with frequency of clk/1024 at minimum. I could set prescaler to a lesser value (not 1024, but 256 for example, then tick frequency is 16000000/256=62500). This means that system timer would have a better precision (it ticks more frequently) but at the same time it reduces maximum possible time delay by 4 times (65536/62500=1.048 seconds).

Thank you, I think I understand now.

Posts: 17
Joined: Sun Nov 12, 2017 7:56 pm
Has thanked: 4 times
Been thanked: 3 times

Re: AVR tickless mode

Postby orion » Tue Nov 06, 2018 10:59 pm

The tickless implementation for the AVR port is not very flexible right now, IMO, for these reasons:
  • As you mentioned, the tick resolution is not configurable since it is hardcoded in os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_st_lld.c to a frequency given by F_CPU/1024
  • Because of the above and a simple implementation using TIMER1, the systime_t type only works correctly when it's 16 bits, and this makes the maximum delay in a virtual timer to be about 4.2 seconds
  • Since it uses TIMER1, the gpt and input capture modules cannot be used in tickless mode; also the use of pwm module with TIMER1 is precluded.
I don't use the tickless mode except for toy examples, but I guess a more flexible implementation would not be that hard.

Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 1 guest