-
-
Notifications
You must be signed in to change notification settings - Fork 732
Update millis.adoc #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update millis.adoc #698
Conversation
Use of millis() may become unreliable if timer0 is reprogrammed, so a small warning might be useful that timer0 is used by millis().
Language/Functions/Time/millis.adoc
Outdated
@@ -64,7 +64,7 @@ void loop() { | |||
|
|||
[float] | |||
=== Notes and Warnings | |||
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. | |||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a great idea to document this. However, I have a question:
Is this true for all architectures officially supported by Arduino?:
We need to be careful to not assume that Arduino == AVR because it's much more than that.
That said, we don't need to worry about covering 3rd party cores in the Arduino Language Reference. It is the responsibility of their authors to document where there are differences from the official Arduino documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, sorry for my late reply. Indeed this warning seems limited to AVR, megaAVR and SAM(D) architectures, as
-ArduinoCore-arc32 uses (but does not reprogram) TIMER0 which is running at 32MHz,
-ArduinoCore-mbed uses a lowPowerTimer if supported, or a Timer otherwise, and there is no limit on the number of such timers
I rewrote the remark, and would welcome your feedback.
Co-authored-by: per1234 <[email protected]>
Thanks for the revised wording! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @Arnold-n. I'm sorry I was so slow in moving this forward, but I guess better late than never?
Use of millis() may become unreliable if timer0 is reprogrammed, so a small warning might be useful that timer0 is used by millis().