Closed
Description
Hello everyone, when I tried to run the example in https://docs.arduino.cc/tutorials/uno-r4-wifi/rtc#Periodic-Interrupt, I found some errors in it.
docs-content/content/hardware/02.hero/boards/uno-r4-wifi/tutorials/rtc/rtc.md
Lines 177 to 216 in 67c3aa5
Here are some issues I believe exist in the code and my suggestions:
- Pin error, Arduino R4 onboard LED is
13
orLED_BUILTIN
, but code uses22
. - Missing
Serial.begin(9600);
. - Missing
RTC.setTime()
. According to RTC_PeriodicExample.inoRTC.setTime()
must be called forRTC.setPeriodicCallback
to work. - Using camel case naming convention and more intuitive naming methods would be better. Refer to the Arduino Style Guide for Creating Libraries. The code mixes camel case naming convention and underscore naming convention. And names like
periodic_cbk
andclb_st
confuse me, perhaps it would be better to not use abbreviations and instead useperiodicCallback
andcallbackStatus
?
- The final suggestion was made by Arduino users van_der_decken and ubidefeo. "It is not recommended to perform lengthy operations within interrupts." "The proper way to use IRQs is generally by setting a flag that will be checked inside your loop." Putting
serial.println()
insideperiodicCallback()
doesn't seem like a wise decision, the code in the example can mislead someone like me who is unfamiliar with rtc.
I also reported this issue on the Arduino community forum, see https://forum.arduino.cc/t/there-may-be-some-conflict-between-rtc-and-the-serial/1169836.
Another related issue is: arduino/ArduinoCore-renesas#138
I hope the document can be improved. Thank you for reading this issue!
Metadata
Metadata
Assignees
Labels
No labels