After setting time of RTC of MKR Zero, I uploaded another sketch, and looking at time again I noticed 10 seconds are missing. So after 6 uploads RTC falls behind a full minute!
Please post your sketch, according to the forum guidelines. Unless, you can make it happen with dummy sketches.
Hi @rnieuwland
This is expected behaviour.
The RTCZero library supplies the 32.768kHz external crystal clock source (OSC32K) through generic clock 2 (GCLK2). (The generic clocks are a means of routing the microcontroller's various clock sources through to its on-chip peripherals, such as the ADC, DAC, TCC/TC timers, RTC, SERCOMs, etc...).
When you attempt to upload another sketch, the bootloader and subsequent Arduino core code essentially pull the plug on GCLK2, thereby depriving the RTC peripheral of its clock source. The connection to GCLK2 is only reestablished once the uploaded sketch finally runs and the RTCZero library initialisation code reconnects it. This is reason why the RTC fails to count for the duration of your upload.
Tx for your elaborate response. Some of your explanation is beyond me, but I understand that there is nothing I can do about is (or install external battery powered clock DSxxxx).
I get that, but as stated, this happens with every sketch.
There isn't any way around that.
How are you setting the RTC in the first place? I always include an RTC setting function in every sketch of mine that uses an RTC. Sometime, it will need to be adjusted anyway, right? Drift, or new battery... same thing with an external RTC module.
To reduce the overhead, I just allow it to accept an integer Epoch time that I get from an Epoch time calculator web site. That is for the units that can't get time automatically from SNTP, GPS etc.
Before that, I parsed a line with YYMMDDHHMMSS data like "2022 10 7 7 3 0". I would enter the time half a minute in advance and then press the enter key when the time is reached to set the clock.
I fully implemented the STM32 on chip RTC on several boards. It's worse in that case, the time is completely wiped clean with a code upload. But I considered the gain in hardware simplicity and size a worthwhile trade off. Especially because the boards are provisioned with battery holder.
Tx again aarg. I'll take some of your advise in consideration. I WILL let you know!
Time or date is not critical in my project. So I decided to let issue not be an issue anymore: got bigger fish to fry (like SERCOM). Still gratefull for you bothering about my question.
I prommised to let you know. Now I find that there are other ways! If you got a modem you can use gsm or pgs. My problem is solved. Tx anyway!!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.