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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-26 10:04 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-26 10:04 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-26 10:34 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 5:23 PM
Hi Pedro, i use your code to set v0u32 = 36 * 60 *60 36 hours,but i found the wakeup period always 24 hours,can not reach 36hours ,can you give some help?i hope the wakeup period can reach 36hours, thanks。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 5:27 PM
Post your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 5:46 PM
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();
}
HAL_PWR_EnterSTANDBYMode();
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 6:03 PM
Hi,
Are you sure it is 24 hours? It looks like you are setting it for 17 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 6:12 PM
Sorry,i mean i want to set 36 hours period time,and i use yours code to change the v0u32,the fact is always 24hours awake,can you give some advices?thanks。
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 6:16 PM
Hi,
I think you cannot set v0u32 = 36 * 60 * 60, if you chose RTC_WAKEUPCLOCK_CK_SPRE_17BITS,
v0u32 value should be 36 * 60 * 60 - 0xFFFF ?
Regards,
Kim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 6:20 PM
You didn't force modulus based on Pedro's answer previously.
v0u32 &= 0x0FFFFUL; /// force modulus
