Including avr/wdt.h obviously doesn't work because it's all written for the wrong processor.
Hi!for RTC, I've rewrited a fork of original arduino Time library for use Internal RTC of 4809 and others MegaAVR 0 series :https://github.com/goodchip/TimeLook at sketchs TimeInternalRTC_xxx in folder "examples"If possible, I would like a return for testing before submitting a pull-request to the original Time project. Thanks!
My fork is fully tranparent with 328p or 4809 chips, just the RTC is used for time generation if you use 4809. (in fact, interrupts features was enabled only if you use 4809).With an external RTC library, the original time library uses millis () between each time update, which is extremely imprecise, especially for time-based sensors applications.Since 4809 uses an internal RTC, I think it is better to use it as a main timebase, which is not possible if not integrated in the time library.Furthermore, it was difficult (if not impossible) to set the righ second with precision ( with setTime() ) if RTC lib is external, with my fork, the real second is set with +/-25µs average precision.
I fully agree that the RTCZero library is well coded, probably in a precise way.Nevertheless, there is for me a contradiction: - on the one hand, you give me an example of use with the library time.h (which is not useful because the library RTCZero includes the vast majority of the functions of the library time.h and without making precision). - on the other hand, you talk about compatibility, but the RTCZero is specific to an architecture while the Time.h is Arduino generalist.My fork brings compatibility between two architectures with all the best possible precision if RTC is present in the chip.Thank you for enlightening me and answer me with arguments.
Arduino Time LibraryA primary goal was to enable date and time functionality that can be used with a variety of external time sources with minimum differences required in sketch logic.
(resistance (black) implanted instead of a capacitor (brown) in the quartz resonator circuit).cf: https://github.com/arduino/ArduinoCore-megaavr/issues/27