RTC, how to configure periodic wake up time of 24h
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-09-26 8:45 PM - edited 2024-09-26 8: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.
- Labels:
-
RTC
-
STM32L0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 6: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。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 6:31 PM - edited 2024-11-06 6: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 6: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。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 6: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 6:56 PM
Hi,
64065 = 17 hours, 47 minutes, 45 seconds...
Kind regards
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 7:14 PM
thanks Kim,the same to you, STM32L071KZT6。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 7: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。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 7: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 7: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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-11-06 8:29 PM
Hi,
Print hrtc.Instance->CR after HAL_RTCEx_SetWakeUpTimer_IT().
Kind regards
Pedro
