We are trying to start a RTC clock and keep the time when we turn off the power.
We are working with a custom board with a Synergy S5D9, with the latest BSP 1.7.0 and E2 Studio ver: 7.3.0.
We have managed to operate the RTC when there is power but if we turn off the device, when we turn it on again the time date has not been updated while there was no voltage.
The electrical circuit is as follows, we use a supercap to maintain tension:
We have measured the signal of the crystal and it gives us the following image both when there is power on and when there is power off:
The configurations in the e2 studio for the CGC, RTC and BSP are as follows:
And the RTC initialization code is as follows:
Can someone help us find the problem?
Thanks in advance.
Is this issue okay now? Did Jeremy's answer helped you solve the problem?
JBRenesasRulz Forum Moderator
Thanks for confirming. It would be better if you create another thread for that issue since this power issue is already solved.
The specs are:
and the external capacitors are 22pF in ours custom board.
The frequency is the image attached in the first post of Hanton,
So the 32kHz crystal appears to be running at 33.82kHz rather than the expected 32.768kHz, however a typical passive scope probe has a capacitance in the range of 10 pF and an input impedance of approximately 10 MΩ. Both values are in the range of the oscillator characteristics and heavily influencethe behaviour of the crystal oscillators.
The load capacitors can also have an effect on the oscillator frequency (The characteristics (pullability curve) of the crystal should be provided by the crystalmanufacturer).
The Synergy devices have a clock out functionality, and the sub oscillator can be selected as the Clock Out Source :-
So it would be better to measure the frequency output by the clock out pin, rather than by probing the 32kHz crystal directly.
Or, you you could use the CAC (Clock Frequency Accuracy Measurement Circuit), to measure the accuracy of the 32kHz clock against a more accurate clock.
32kHz tuning fork crystals exhibit a relatively high frequency drift over temperature. If you look at the specs of the Abracom 32kHz crystal used on the S7G2-SK board :-
The turn over temperature is typ 25C, and Temperature Coefficient is typ -0.036 ppm/(T*T). Assuming 0-ppm at the turn around frequency (25C) you would get a frequency deviation over the operating temperature of -40C to +85C for the Abracom crystal of (X axis is temperature in C, Y axis is frequency deviation in PPM):-
So you will probably need to use some sort of compensation if you want to be as accurate as possible over as wide a temperature range as possible.
If you know how far adrift the 32 kHz crystal is (either by using the CAC to measure it against a more accurate clock, or by measuring the ambient temperature and working out the drift using the datasheet parameters), the RTC has a Time Error Adjustment feature :-
The manual gives some examples of using the Time Error Adjustment function, however, the error in the 32kHz Sub Oscillator frequency needs to be known to use this feature.