hi, I am using STM32F103C8T6 microcontroller to get current Time and date. I am using Arduino IDE for this project. Since the microcontroller has in-buid RTC, i am using it. I used RTClock.h library. I used the example program “Test_RTClock” . In the setup function, i initially set the epoch time by myself using rt.setTime() function. And i did not change anything in the loop function. So, as example, it should print the epoch time for every 1 second.
But, case(1),As i executed the code, i found that the microcontroller prints the correct time at first execution and it takes more than actual 1second to print the next RTCsecond. And again it takes more than actual 1second to Print the next second. and thus IF WE SEE, after few minutes, the MICROCONTROLLER’s time is very much delayed when compared to the actual time.
Also if i re-upload (case:2) the code, it prints actual time at first, and then the controller prints delayed time when compared with Actual time.
Also in both the cases, the delay is not same.
First time uploading the code: In first case it takes, 1115 milliseconds to chance a first second and not 1000msec. Then it takes 1405 milliseconds to chance the next second, then it takes 1200 milliseconds to change the next second. here, the millisecond change is random and not 1000ms.
Second time uploading the code: In this case it takes, 1100 milliseconds to chance a first second. Then it takes 1665 milliseconds to chance the next second, then it takes 1455 milliseconds to change the next second. here also, the milli second change is random.
we could see, on every upload, the RTCcounter takes different/random milliseconds and not the actual 1000millisecond.
What causes this random changes ? Does RTC counter doesnot work properly? Somebody kindly help me to fix this issue…