2024-09-26 08:45 PM - edited 2024-09-26 08:49 PM
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?
Solved! Go to Solution.
2024-11-06 06:21 PM
thanks Kim,i know you mean,but my code is set if v0u32 = 36 * 60 * 60,
if( v0u32 > 0xFFFF )
{
v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_17BITS;
v0u32 &= 0xFFFF;
}
v0u32 &= 0xFFFF the same as 36 * 60 * 60 - 0xFFFF,
thanks。
2024-11-06 06:31 PM - edited 2024-11-06 06:41 PM
Hi freedomcain,
Thanks for pointing out.
I think compiler do the typecasting by convert 0xFFFF to 32 bits and probably overflow occured , as you see that it is important to putting 'UL' in constant value of 0x0FFFFUL, maybe you can print the result of v0u32 &= 0xFFFF, for obeservation. I'm not sure.
Regards,
Kim
2024-11-06 06:41 PM
thanks kim,the result is the same,i print hrtc.Instance->WUTR param is 64065,the same as 36 * 60 * 60 - 0xFFFF。so how can i set the period time more than 18 hours ,24 hours,please help,thanks。
2024-11-06 06:56 PM
What series of MCU are you using, I'm using STM32L071, not sure if different series have different wake up period time range to set, could you check the datasheet?
2024-11-06 06:56 PM
Hi,
64065 = 17 hours, 47 minutes, 45 seconds...
Kind regards
Pedro
2024-11-06 07:14 PM
thanks Kim,the same to you, STM32L071KZT6。
2024-11-06 07:17 PM
thanks Pedro,but i set RTC_WAKEUPCLOCK_CK_SPRE_17BITS,so how can i set the period time more than 18 hours ,24 hours,can you give some code advice,thanks。
2024-11-06 07:23 PM
Hi,
Provide evidence that the RTC_WAKEUPCLOCK_CK_SPRE_17BITS is set.
Provide evidence that the timer is ALWAYS 24 hours.
Kind regards
Pedro
2024-11-06 07:47 PM
i use this code to set RTC_WAKEUPCLOCK_CK_SPRE_17BITS, debug can comfirm the RTC_WAKEUPCLOCK_CK_SPRE_17BITS is set,so if i set RTC_WAKEUPCLOCK_CK_SPRE_17BITS, v0u32 = 64065,the fact is 17 hours, how can i set the period time more than 24 hours if v0u32 = 129600,can you give some code advice? thanks
unsigned int v0u32 = 36 * 60 * 60,v1u32 = 0;
if( v0u32 > 0xFFFF )
{
v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_17BITS;
v0u32 &= 0xFFFF;
}
else
{
v1u32 = RTC_WAKEUPCLOCK_CK_SPRE_16BITS;
}
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, v0u32, v1u32) != HAL_OK)
{
Error_Handler();
}
2024-11-06 08:29 PM
Hi,
Print hrtc.Instance->CR after HAL_RTCEx_SetWakeUpTimer_IT().
Kind regards
Pedro