Skip to content

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

Merged
merged 5 commits into from
May 8, 2022
Merged

Update millis.adoc #698

merged 5 commits into from
May 8, 2022

Conversation

Arnold-n
Copy link
Contributor

Use of millis() may become unreliable if timer0 is reprogrammed, so a small warning might be useful that timer0 is used by millis().

Use of millis() may become unreliable if timer0 is reprogrammed, so a small warning might be useful that timer0 is used by millis().
@@ -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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

@Arnold-n Arnold-n requested a review from per1234 September 21, 2021 19:38
@per1234 per1234 self-assigned this May 7, 2022
@Arnold-n
Copy link
Contributor Author

Arnold-n commented May 8, 2022

Thanks for the revised wording!

Copy link
Collaborator

@per1234 per1234 left a 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?

@per1234 per1234 merged commit 01b5617 into arduino:master May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants