2021-05-26 10:49 PM
The RTC looses 15 min every 8 hour aprox when the main power is on. I have selected the LSE as the RTC clock, as i show in the images, and i have a 32.768 Khz 10 ppm crystal with a 9 pF load. I thought that maybe it was due to a bad match of the crystal capacitors but the RTC works fine when the main power is off! I really dont know what is going on... Thanks in advance.
Solved! Go to Solution.
2021-05-31 07:14 AM
> counts 21,22,23...and suddenly jumps to 31,32...But i dont know if it is normal.
No, this is not normal. I reiterate my above recommendation:
review the area around the crystal - aren't there any high-current track nearby? Are tracks short, especially ground? You can try to output the LSE to a pin (MCO or similar, if there's such facility on the 'F373) and observe using logic analyzer if it's regular, etc.,
You may also want to selectively remove parts of your code which exercise pins/tracks which are in the vicinity of the LSE circuitry, or which control high power/high frequency outputs.
JW
2021-05-26 11:54 PM
Do you switch off/on or reset in any other way the 'F373 often?
The Hal RTC init sets the INIT bit in RTC, which causesthe subseconds to be cleared. The net effect is, that each reset results in average in half a second to be "lost". Search here on the forum, this is a recurring theme.
JW
2021-05-27 12:18 AM
I have seen this issue but i dont reset or swith off the F373. It spends 8 hour power on and it looses 15 min aprox, after that it spends 8 hour power off and it does not loose any minute.
2021-05-27 12:48 AM
As an experiment, remove any code related to the RTC from your program - once enabled, it keeps running and you still can read it in debugger (of BYPSHD is cleared, you may need to read it twice, but that's just a detail). Now run your code for a day - still not good?
If not, review the area around the crystal - aren't there any high-current track nearby? Are tracks short, especially ground? You can try to output the LSE to a pin (MCO or similar, if there's such facility on the 'F373) and observe using logic analyzer if it's regular, etc., but this is a lengthy procedure with unsure results.
JW
2021-05-28 06:01 AM
In the program i call HAL_RTC_GetTime and HAL_RTC_GetDate several times per second, in order to refresh the date and time of the system. I have tried to user this functions only when i press a button and it seems that doing this the system does not loose time. Could this be the problem? In that case how could i refresh the date and time continuously?
2021-05-28 09:19 AM
> I have tried to use this functions only when i press a button and it seems that doing this the system does not loose time.
These functions alone shouldn't do anything harmful. You ought to read date always after reading time, though, unless you have BYPSHD set.
Did you block out something else?
JW
2021-05-31 05:35 AM
I was reading already the date after the time. But now i am trying to read it two times each. I am going to be testing it this week so i will keep you inform. Thank you very much
2021-05-31 06:28 AM
i have removed all the interactions with the RTC, now while debugging i am watching the TR register and it increases at 1 Hz but sometimes it jumps , for example it counts 21,22,23...and suddenly jumps to 31,32...But i dont know if it is normal. In case it is normal how could i read the time in order to see if it has not lose any seconds or minutes?
2021-05-31 07:14 AM
> counts 21,22,23...and suddenly jumps to 31,32...But i dont know if it is normal.
No, this is not normal. I reiterate my above recommendation:
review the area around the crystal - aren't there any high-current track nearby? Are tracks short, especially ground? You can try to output the LSE to a pin (MCO or similar, if there's such facility on the 'F373) and observe using logic analyzer if it's regular, etc.,
You may also want to selectively remove parts of your code which exercise pins/tracks which are in the vicinity of the LSE circuitry, or which control high power/high frequency outputs.
JW
2021-05-31 11:02 PM
Okay, i am going to do some tests in the hardware to see if i find the problem. Thank you very much for the answers