Skip to main content
Associate III
September 27, 2024
Solved

RTC, how to configure periodic wake up time of 24h

  • September 27, 2024
  • 23 replies
  • 8087 views

Hi, I'm using STM32L0 series MCU to configure the RTC to wake up after 24 hour during sleep/standby mode. Understand that we need to configure the Wake up clock to use 1Hz with 1 bit wake up counter added so that it can have the wake up time from 18h to ~36h.

Anyone know what number of wake up counter I have to set in order to have 24 hours wake up time? The wake up counter is 16 bit with max value of 65535.

if configure the Wake up clock to use 1Hz with 1 bit wake up counter added (RTC_WAKEUPCLOCK_CK_SPRE_17BITS), we can set the wake up time range from < 1hour up to 36h  or from 18h up to 36h?

 

chai2145_0-1727408466608.png

 

This topic has been closed for replies.
Best answer by PGump.1

Hi,

This is the way I do it in code...

	 		 V0u32 = 24 * 60 * 60; /// set for 24 hours
	 		 /// test/ limit timer to 17bits
	 		 if (v0u32 >= 0x10000UL) {		/// ? greater than 16bit
	 			 v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_17BITS;
	 			 v0u32 &= 0x0FFFFUL;		/// force modulus
	 		 }
	 		 else {
	 			 v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_16BITS;
	 		 }
	 		 HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, v0u32, v1u32);

 I hope this helps.

Kind regards
Pedro

23 replies

PGump.1
PGump.1Best answer
Senior II
September 27, 2024

Hi,

This is the way I do it in code...

	 		 V0u32 = 24 * 60 * 60; /// set for 24 hours
	 		 /// test/ limit timer to 17bits
	 		 if (v0u32 >= 0x10000UL) {		/// ? greater than 16bit
	 			 v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_17BITS;
	 			 v0u32 &= 0x0FFFFUL;		/// force modulus
	 		 }
	 		 else {
	 			 v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_16BITS;
	 		 }
	 		 HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, v0u32, v1u32);

 I hope this helps.

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
chai2145Author
Associate III
September 27, 2024

Thank you Pedro, meaning my assumption is correct, if using RTC_WAKEUPCLOCK_CK_SPRE_17BITS, the wake up time will be range from 18h to ~36h