Skip to content

Commit bed5bee

Browse files
authored
Clarification TIMx use by AVR architectures
1 parent f771089 commit bed5bee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Language/Functions/Time/millis.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ void loop() {
6464

6565
[float]
6666
=== Notes and Warnings
67-
Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart. millis() uses timer0's overflow interrupt.
67+
Please note that the return value for millis() is of type `unsigned long`, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as `int`. Even signed `long` may encounter errors as its maximum value is half that of its unsigned counterpart.
68+
69+
AVR-based architectures program a timer to implement millis(), reconfiguring these timers may result in inaccurate millis() readings. ArduinoCore-AVR relies on TIM0 which is programmed to generate an interrupt every 16384 clock cycles (clock divider set to 64, overflow every 256 ticks). The same holds for ArduinoCore-mega-AVR, except that it uses TIMx if MILLIS_USER_TIMx (0<=x<=3) is defined.
6870

6971
--
7072
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)