how to designate wakeup msec by HAL_RTCEx_SetWakeUpTimer()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 2:09 AM
Hello,
Now I mean to generate periodic wake-up by HAL_RTCEx_SetWakeUpTimer().
But I'm not sure about arguments WakeUpCounter and WakeUpClock.
For realize 50msec wake-up what value should be set to WakeUpCounter and which RTCCLK_DIV should be selected.
Thanks
Solved! Go to Solution.
- Labels:
-
STM32L0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-20 1:06 AM - edited ‎2024-12-20 1:28 AM
Hello @curiae
To generate a periodic wake-up using HAL_RTCEx_SetWakeUpTimer() for a 50ms interval, you need to set the WakeUpCounter and WakeUpClock arguments appropriately.
WakeUpClock: This parameter determines the clock source for the wake-up timer. The available options are typically:
- RTC_WAKEUPCLOCK_RTCCLK_DIV16
- RTC_WAKEUPCLOCK_RTCCLK_DIV8
- RTC_WAKEUPCLOCK_RTCCLK_DIV4
- RTC_WAKEUPCLOCK_RTCCLK_DIV2
- RTC_WAKEUPCLOCK_CK_SPRE_16BITS
- RTC_WAKEUPCLOCK_CK_SPRE_17BITS
WakeUpCounter: This parameter sets the counter value for the wake-up timer. The counter value is calculated based on the desired wake-up interval and the selected clock source.
To achieve a 50ms wake-up interval, you need to calculate the appropriate counter value based on the selected clock source. For example, if you choose RTC_WAKEUPCLOCK_RTCCLK_DIV16, the calculation would be as follows:
Assume the RTCCLK is 32.768 kHz (LSE clock).
- The clock source after division by 16 would be 32.768 kHz / 16 = 2.048 kHz.
- The period of this clock source is 1 / 2.048 kHz = 0.48828125 ms.
- To achieve a 50ms interval, the counter value should be 50ms / 0.48828125ms ≈ 102.4.
Since the counter value must be an integer, you can round it to 102.
Thanks
Omar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-20 1:06 AM - edited ‎2024-12-20 1:28 AM
Hello @curiae
To generate a periodic wake-up using HAL_RTCEx_SetWakeUpTimer() for a 50ms interval, you need to set the WakeUpCounter and WakeUpClock arguments appropriately.
WakeUpClock: This parameter determines the clock source for the wake-up timer. The available options are typically:
- RTC_WAKEUPCLOCK_RTCCLK_DIV16
- RTC_WAKEUPCLOCK_RTCCLK_DIV8
- RTC_WAKEUPCLOCK_RTCCLK_DIV4
- RTC_WAKEUPCLOCK_RTCCLK_DIV2
- RTC_WAKEUPCLOCK_CK_SPRE_16BITS
- RTC_WAKEUPCLOCK_CK_SPRE_17BITS
WakeUpCounter: This parameter sets the counter value for the wake-up timer. The counter value is calculated based on the desired wake-up interval and the selected clock source.
To achieve a 50ms wake-up interval, you need to calculate the appropriate counter value based on the selected clock source. For example, if you choose RTC_WAKEUPCLOCK_RTCCLK_DIV16, the calculation would be as follows:
Assume the RTCCLK is 32.768 kHz (LSE clock).
- The clock source after division by 16 would be 32.768 kHz / 16 = 2.048 kHz.
- The period of this clock source is 1 / 2.048 kHz = 0.48828125 ms.
- To achieve a 50ms interval, the counter value should be 50ms / 0.48828125ms ≈ 102.4.
Since the counter value must be an integer, you can round it to 102.
Thanks
Omar
