Well, @Shilpashree Madhu, you already took your code from there, right?
But let's analyze the code again and your modification:
- we assume you are using LSE with a crystal of 32.768kHz
- predivider:
- line 188: the asynchronous predivider is set to 127+1 = 2^7
- line 189: the synchronous predivider is set to 255+1 = 2^8
- together they give a predivider of 2^7 * 2^8 = 2^15 = 32768, which creates an RTC input clock (ck_spre) of 2^15Hz / 2^15 = 1Hz
- RTC:
- line 104: RTC gets its clock from RTC_WAKEUPCLOCK_CK_SPRE_17BITS, which adds 0x10000 = 65536 to the register WUT (see reference [1] at the bottom)
- line 104: WUT is set to 0x3C08D = 245901
- so it'll take 245901 + 65536 +1 = 311438 clock cycles of ck_spre to raise a WakeUp interrupt
- periodic time for the interrupt will be WUT(total) / ck_spre = 311438 / 1Hz = 311438s
It means you will see an interrupt, i.e. a wakeup, after 3 days 14 hours 30 minutes, 38 secs. :D
Please change:
- RTC_WAKEUPCLOCK_CK_SPRE_17BITS to RTC_WAKEUPCLOCK_CK_SPRE_16BITS
- 0x3C08D to 119 (or 0x77, if you prefer)
then you should get a 1 second flash every 2 minutes.
[1] see RM0432, section 46.6.3 RTC control register RTC_CR, bits WUCKSEL:
WUT = Wakeup unit counter value. WUT = (0x0000 to 0xFFFF) + 0x10000 added when WUCKSEL[2:1 = 11].
--> WUCKSEL[2:1 = 11] = RTC_WAKEUPCLOCK_CK_SPRE_17BITS
Does it answer your question?
Regards
/Peter