2019-07-30 10:42 AM
Hello everyone,
I am currently developing a code for my custom board that has BLE communication along with RTC and timer(PWM) initialized. I am currently testing my code first on the PNucleoWB55 development board. The issue is that the normal RTC_Alarm Example from the SDK is working fine and alarm interrupt occurs exactly after 30 seconds. However, when I initialize the RTC in BLE_p2pServer, the RTC interrupt occurs much quicker (approx 5 seconds when programmed to occur after 30 seconds). What could be the issue? If someone can help me, I shall be grateful.
Solved! Go to Solution.
2019-07-31 05:57 AM
The LSI is 32KHz +/-5% tolerance. If your RTC is running fast the reason is the oscillator is not exactly 32KHz.
The RTCCLK one second tick uses two dividers, async and sync, to divide down the nominal 32KHz input to 1Hz. Set the async prescaler to 32, and the sync prescaler to 1000 +/- a calibration value. You'll have to determine how far off your LSI is (and this will vary by temperature) to calculate that calibration factor.
I use an 'L476 Discovery eval board with the RTC driven by LSI. In my particular case the sync prescaler is set to 1014 instead of 1000, or an LSI of about 32.45KHz. This still doesn't yield the same accuracy as an LSE crystal but the daily deviation is under 60 seconds, rather than several minutes. That's good enough for my application, which isn't time of day critical.
Since you're running fast on the RTC try increasing the synchronous prescaler. I don;t use Cube so no idea how to change the prescaler with it.
Jack Peacock
2019-07-30 11:01 AM
LSI and LSE typical need different prescalers to address the frequency differences.
2019-07-31 05:22 AM
I am using LSI in my case for RTC. How to adjust the prescaler?
According to clock configuration diagram in CubeMX, the clock being supplied to RTC is 32Khz from LSI which is the same as in RTC_Alarm Example.
2019-07-31 05:57 AM
The LSI is 32KHz +/-5% tolerance. If your RTC is running fast the reason is the oscillator is not exactly 32KHz.
The RTCCLK one second tick uses two dividers, async and sync, to divide down the nominal 32KHz input to 1Hz. Set the async prescaler to 32, and the sync prescaler to 1000 +/- a calibration value. You'll have to determine how far off your LSI is (and this will vary by temperature) to calculate that calibration factor.
I use an 'L476 Discovery eval board with the RTC driven by LSI. In my particular case the sync prescaler is set to 1014 instead of 1000, or an LSI of about 32.45KHz. This still doesn't yield the same accuracy as an LSE crystal but the daily deviation is under 60 seconds, rather than several minutes. That's good enough for my application, which isn't time of day critical.
Since you're running fast on the RTC try increasing the synchronous prescaler. I don;t use Cube so no idea how to change the prescaler with it.
Jack Peacock
2019-07-31 06:38 AM
I got it working after your suggestion. Thanks alot.
2019-08-15 08:46 AM
Hi @AKetc ,
Please select the best answer that helped you.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.