cancel
Showing results for 
Search instead for 
Did you mean: 

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

chai2145
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGump.1
Senior II

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.

View solution in original post

2 REPLIES 2
PGump.1
Senior II

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.

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