{"id":4261,"date":"2020-04-15T20:00:22","date_gmt":"2020-04-15T18:00:22","guid":{"rendered":"https:\/\/msalamon.pl\/?p=4261"},"modified":"2025-12-27T17:29:21","modified_gmt":"2025-12-27T16:29:21","slug":"additional-rtc-functions-in-stm32f4-part-2","status":"publish","type":"post","link":"https:\/\/msalamon.pl\/en\/additional-rtc-functions-in-stm32f4-part-2\/","title":{"rendered":"Additional RTC Functions in STM32F4 Part 2"},"content":{"rendered":"\n<p>The built-in RTC clock in STM32 has so many features that I had to split their description into two posts. Previously, I showed you the cool stuff related to \u201cbreak-ins\u201d. This time we\u2019ll wake the sleeper up \ud83d\ude42<\/p>\n\n\n\n<!--more-->\n\n\n\n<h1 class=\"wp-block-heading\">\u201cWake-up\u201d RTC features in STM32F4<\/h1>\n\n\n\n<p>Now we\u2019ll take a look at two similar, yet different clock features that can wake us up\u2014but not only us:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wake Up<\/li>\n\n\n\n<li>Alarms<\/li>\n<\/ul>\n\n\n\n<p>Let me base this on the board I chose in the previous article. It\u2019s the so-called <a href=\"https:\/\/sklep.msalamon.pl\/produkt\/stm32f401ccu6-dev-board\/?utm_source=blog&amp;utm_medium=article&amp;utm_campaign=rtc_features&amp;utm_content=Text\">BlackPill with an STM32F401<\/a> on board. You can buy <a href=\"https:\/\/sklep.msalamon.pl\/produkt\/stm32f401ccu6-dev-board\/?utm_source=blog&amp;utm_medium=post&amp;utm_campaign=rtcf4\">such a board<\/a> (or a <a href=\"https:\/\/sklep.msalamon.pl\/produkt\/stm32f411ceu6-dev-board\/?utm_source=blog&amp;utm_medium=post&amp;utm_campaign=rtcf4\">slightly more powerful one<\/a>) from me.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/sklep.msalamon.pl\/produkt\/stm32f411ceu6-dev-board\/?utm_source=blog&amp;utm_medium=banner&amp;utm_campaign=rtc_features&amp;utm_content=blackpill\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"400\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner.jpg\" alt=\"stm32f411\" class=\"wp-image-1326\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner.jpg 1200w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-300x100.jpg 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-1024x341.jpg 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-768x256.jpg 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-24x8.jpg 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-36x12.jpg 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2019\/12\/BlackPill-baner-160x53.jpg 160w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>The software I\u2019ll use is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>STM32CubeIDE v1.2.0<\/li>\n\n\n\n<li>STM32CubeMX v5.5.0 built into the IDE<\/li>\n\n\n\n<li>HAL F4 v1.24.2<\/li>\n<\/ul>\n\n\n\n<p>I\u2019ll also base this on the <a href=\"https:\/\/github.com\/lamik\/RTC_F401\" target=\"_blank\" rel=\"noopener\">project I created for STM32F4<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wake Up in STM32<\/h2>\n\n\n\n<p>The name itself gives away what it\u2019s for. The Wake Up function is used to wake the microcontroller from low-power modes. In this mode, not all clocks or peripherals are running. A lot depends on which mode we choose. The F series has a modest list of possibilities in this regard, but the L series already has tons of combinations of these modes.<\/p>\n\n\n\n<p>Using this function, in short, comes down to setting the appropriate timer in the RTC and entering sleep mode. After the specified time elapses, our microcontroller will be woken up by an interrupt, which of course we can handle\u2014unless it\u2019s an \u201caggressive\u201d Low Power mode in which memories are not retained and the program starts from the beginning.<\/p>\n\n\n\n<p>How to set it up? In Cube you need to select that you want to use Wake Up.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"324\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube.png\" alt=\"\" class=\"wp-image-1456\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube.png 795w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube-300x122.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube-768x313.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube-24x10.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube-36x15.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube-160x65.png 160w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/figure>\n<\/div>\n\n\n<p>A Wake UP section will appear in the configuration, where you can set the clock for the dedicated Timer and the counter itself.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"83\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2.png\" alt=\"\" class=\"wp-image-1457\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2.png 780w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2-300x32.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2-768x82.png 768w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2-24x3.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2-36x4.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_cube2-160x17.png 160w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/figure>\n<\/div>\n\n\n<p>For tests I selected the RTC clock divided by 16. The larger the divider (smaller clock), the less energy the RTC Wake Up module will consume while the MCU is asleep.<\/p>\n\n\n\n<p>Don\u2019t set the counter itself in Cube. That actually makes no sense. Why?<\/p>\n\n\n\n<p>First, we don\u2019t want to wake up right after program start, when we still don\u2019t know when we\u2019re going to sleep. Cube unfortunately sets the clock immediately during initialization and enables its interrupt. Total nonsense.<\/p>\n\n\n\n<p>Second, in the RTC initialization function we have an earlier return inserted a bit above, so as not to overwrite the date and time with values from Cube, so the code will never reach the WakeUp timer setup.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"540\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init.png\" alt=\"\" class=\"wp-image-1458\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init.png 637w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init-300x254.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init-24x20.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init-36x31.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup_init-94x80.png 94w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>So when and how to use it?<\/p>\n\n\n\n<p>You set it right before entering sleep. For this, I created a special function <em>Enter_LowPowerMode<\/em> in user section #4, where I set the WakeUp counter and enter STOP Mode. I based it on an example from the HAL library.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void Enter_LowPowerMode(void)\n{\n  \/*## Enter STOP low power Mode ##########################################*\/\n  \/**\n  RTC Wakeup Interrupt Generation:\n  Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV \/(LSE or LSI))\n  Wakeup Time = Wakeup Time Base * WakeUpCounter\n              = (RTC_WAKEUPCLOCK_RTCCLK_DIV \/(LSE or LSI)) * WakeUpCounter\n  ==&amp;gt; WakeUpCounter = Wakeup Time \/ Wakeup Time Base\n\n  To configure the wake up timer to 5 s the WakeUpCounter is set to 0x2FA8:\n  RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16\n  Wakeup Time Base = 16 \/(~32.000KHz) = ~0,5 ms\n  Wakeup Time = 5 s = 0,5ms  * WakeUpCounter\n  ==&amp;gt; WakeUpCounter = 5\/0,5ms = 0x2710\n\t**\/\n  HAL_RTCEx_SetWakeUpTimer_IT(&amp;amp;hrtc, 0x2710, RTC_WAKEUPCLOCK_RTCCLK_DIV16);\n\n  HAL_SuspendTick();      \t\t\t\/* To Avoid timer wake-up. *\/\n\n  \/**\n\tIn PWR_MAINREGULATOR_ON mode, we measure 13.8\/15.2uA on JP6\n\t**\/\n  HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON,PWR_STOPENTRY_WFI);\n\n  \/**\n  In PWR_LOWPOWERREGULATOR_ON mode, we measure 1.3\/2.7uA on JP6\n  HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);\n\t**\/\n\n  \/* We are now waiting for TAMPERF1 or WAKEUP interrupts (or Reset) *\/\n\n  HAL_ResumeTick();       \/* Needed in case of Timer usage. *\/\n  HAL_RTCEx_DeactivateWakeUpTimer(&amp;amp;hrtc);\n\n  SystemClock_Config();   \/* Re-configure the system clock *\/\n}<\/pre>\n\n\n\n<p>In the comments you can see that you need to calculate the counter value that we set. There is a simple formula for this.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV \/(LSE or LSI)), i.e., the base tick of the WakeUp timer. I chose a divider of 16 and I use the internal oscillator, so 16\/32000 = 0.0005 s, i.e. 0.5 ms.<\/li>\n\n\n\n<li>Wakeup Time = Wakeup Time Base * WakeUpCounter, i.e., the time after which the MCU should wake up. If you want it to do this about every 5 seconds, then the formula looks like this<br>5 = 0.0005 * WakeUpCounter\u00a0<\/li>\n\n\n\n<li>WakeUpCounter = Wakeup Time \/ Wakeup Time Base, i.e. by mathematically swapping sides our calculations will look like this<br>WakeUpCounter = 5 \/ 0.0005 = 10000 (dec) = 0x2710 (hex) and this value must be entered into the Wake Up counter<\/li>\n<\/ul>\n\n\n\n<p>Before entering STOP Mode it\u2019s worth stopping SysTick, because its interrupt can also wake the MCU \ud83d\ude42<\/p>\n\n\n\n<p>The HAL_PWR_EnterSTOPMode function enters STOP Mode with the possibility of waking up via interrupt, so the RTC WakeUp interrupt is able to wake our MCU. What happens right after that function is executed after waking up.<\/p>\n\n\n\n<p>After waking up, I resume SysTick, disable WakeUp, and continue. The test program happens to cyclically put the MCU to sleep and wake it. In the terminal it looks like this.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"441\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup.png\" alt=\"\" class=\"wp-image-1459\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup.png 688w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup-300x192.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup-24x15.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup-36x23.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_wakeup-125x80.png 125w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>It wakes up and falls asleep. That\u2019s a magician\u2019s role. <a href=\"https:\/\/github.com\/lamik\/RTC_F401\/tree\/wakeup\" target=\"_blank\" rel=\"noopener\">You can find the full example code here.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">RTC Alarm in STM32F4<\/h2>\n\n\n\n<p>The last function I wanted to show you is the Alarm. It works similarly to an alarm clock that you set every evening.<\/p>\n\n\n\n<p>When the clock matches the alarm, an interrupt is generated. This interrupt can of course be handled, or used to wake the microcontroller from sleep. How to enable the alarm?<\/p>\n\n\n\n<p>You just have to\u2026 enable it in Cube \ud83d\ude42<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"293\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube.png\" alt=\"\" class=\"wp-image-1470\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube.png 565w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube-300x156.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube-24x12.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube-36x19.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube-154x80.png 154w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>This setting causes the alarm signaling to be routed internally within the MCU. You can also activate the alarm on a microcontroller pin.<\/p>\n\n\n\n<p>Of course, additional configuration related to the Alarm will appear.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"245\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2.png\" alt=\"\" class=\"wp-image-1471\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2.png 666w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2-300x110.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2-24x9.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2-36x13.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm_cube2-160x59.png 160w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/figure>\n<\/div>\n\n\n<p>Here you\u2019ll find settings not only for time and date. You can set a bit more combinations, such as generating an alarm every minute. All of this using masks. I recommend playing around and testing.<\/p>\n\n\n\n<p>However, it\u2019s much better to set the alarm from code, and that\u2019s what I did. I wrote a simple function that sets the alarm five seconds ahead of the current time. Note: this doesn\u2019t work long-term. When the hour changes, the algorithm already falls apart. Writing a well-working algorithm was not my goal \ud83d\ude42<\/p>\n\n\n\n<p>I use a separate function for this.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void SetNextAlarm(void)\n{\n\tRTC_AlarmTypeDef sAlarm = {0};\n\n\t\/** Enable the Alarm A\n\t * WARNING: It doesn't work if hour changes and further.\n\t*\/\n\tsAlarm.AlarmTime.Hours = RtcTime.Hours;\n\tsAlarm.AlarmTime.Minutes = RtcTime.Minutes + ((RtcTime.Seconds + 5) \/ 60);\n\tsAlarm.AlarmTime.Seconds = (RtcTime.Seconds + 5) % 60;\n\tsAlarm.AlarmTime.SubSeconds = 0;\n\tsAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;\n\tsAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;\n\tsAlarm.AlarmMask = RTC_ALARMMASK_NONE;\n\tsAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;\n\tsAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;\n\tsAlarm.AlarmDateWeekDay = RtcDate.Date;\n\tsAlarm.Alarm = RTC_ALARM_A;\n\tif (HAL_RTC_SetAlarm_IT(&amp;amp;hrtc, &amp;amp;sAlarm, RTC_FORMAT_BIN) != HAL_OK)\n\t{\n\t\tError_Handler();\n\t}\n}<\/pre>\n\n\n\n<p>Meanwhile, I handle the alarm in such a way that in its interrupt I only set a global flag.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)\n{\n\tAlarmFlag = 1;\n}<\/pre>\n\n\n\n<p>And I handle this flag in the main loop between reading the current time from the RTC.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  \/* USER CODE BEGIN WHILE *\/\n  while (1)\n  {\n\t  HAL_RTC_GetTime(&amp;amp;hrtc, &amp;amp;RtcTime, RTC_FORMAT_BIN);\n\t  Milliseconds = ((RtcTime.SecondFraction-RtcTime.SubSeconds)\/((float)RtcTime.SecondFraction+1) * 100);\n\t  HAL_RTC_GetDate(&amp;amp;hrtc, &amp;amp;RtcDate, RTC_FORMAT_BIN);\n\n\t  if(RtcTime.Seconds != CompareSeconds)\n\t  {\n\t\t  MessageLen = sprintf((char*)Message, \"Date: %02d.%02d.20%02d Time: %02d:%02d:%02d:%02d\\n\\r\", RtcDate.Date, RtcDate.Month, RtcDate.Year, RtcTime.Hours, RtcTime.Minutes, RtcTime.Seconds, Milliseconds);\n\t\t  HAL_UART_Transmit(&amp;amp;huart2, Message, MessageLen, 100);\n\t\t  CompareSeconds = RtcTime.Seconds;\n\t  }\n\n\t  if(AlarmFlag == 1)\n\t  {\n\t\tMessageLen = sprintf((char*)Message, \"Alarm?! I'll set snooze for 5 seconds...\\n\\r\");\n\t\tHAL_UART_Transmit(&amp;amp;huart2, Message, MessageLen, 100);\n\n\t\tSetNextAlarm();\n\t\tAlarmFlag = 0;\n\t  }\n\n\t  if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(TEST_GPIO_Port, TEST_Pin))\n\t  {\n\t\t while(GPIO_PIN_RESET == HAL_GPIO_ReadPin(TEST_GPIO_Port, TEST_Pin))\n\t\t {}\n\t\t SetRTC();\n\t  }\n    \/* USER CODE END WHILE *\/\n\n    \/* USER CODE BEGIN 3 *\/\n  }\n  \/* USER CODE END 3 *\/<\/pre>\n\n\n\n<p>The result?<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"441\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm.png\" alt=\"\" class=\"wp-image-1469\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm.png 688w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm-300x192.png 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm-24x15.png 24w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm-36x23.png 36w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/03\/rtcf4_alarm-125x80.png 125w\" sizes=\"auto, (max-width: 688px) 100vw, 688px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Snooze every 5 seconds. Feels like me every morning \ud83d\ude42<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/lamik\/RTC_F401\/tree\/alarm\" target=\"_blank\" rel=\"noopener\">You can find the full example code here.<\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/sklep.msalamon.pl\/kategoria-produktu\/dev-boardy\/stm32-nucleo\/?utm_source=blog&amp;utm_medium=banner&amp;utm_campaign=rtc_features&amp;utm_content=nucleo\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"400\" src=\"http:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner.jpg\" alt=\"\" class=\"wp-image-1593\" srcset=\"https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner.jpg 1200w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-300x100.jpg 300w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-1024x341.jpg 1024w, https:\/\/msalamon.pl\/wp-content\/uploads\/2020\/07\/Nucleo-64-baner-768x256.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>You\u2019ve learned two more features of the built-in RTC. Alarms can remind us about certain things far in the future. Thanks to this, we relieve the CPU from constantly checking \u201cis it time yet?\u201d. The Wake Up function can turn out to be incredibly useful in battery-powered devices.<\/p>\n\n\n\n<p>You can find the full project along with the library as usual on my GitHub: <a href=\"https:\/\/github.com\/lamik\/RTC_F401\" target=\"_blank\" rel=\"noopener\">LINK<\/a><\/p>\n\n\n\n<p><span>If you noticed an error, disagree with something, would like to add something important, or simply feel like you\u2019d like to discuss this topic, write a comment. Remember that the discussion should be polite and in accordance with the rules of the Polish language.<\/span><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;4261&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;0&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Additional RTC Functions in STM32F4 Part 2&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 0px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\"><\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The built-in RTC clock in STM32 has so many features that I had to split their description into two posts. Previously, I showed you the cool stuff related to \u201cbreak-ins\u201d. This time we\u2019ll wake the sleeper up \ud83d\ude42<\/p>\n","protected":false},"author":1,"featured_media":3430,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[160],"tags":[175,178,174],"class_list":["post-4261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stm32","tag-electronics","tag-kursstm32","tag-stm32"],"_links":{"self":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/comments?post=4261"}],"version-history":[{"count":3,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4261\/revisions"}],"predecessor-version":[{"id":4373,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/posts\/4261\/revisions\/4373"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/media\/3430"}],"wp:attachment":[{"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/media?parent=4261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/categories?post=4261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/msalamon.pl\/en\/wp-json\/wp\/v2\/tags?post=4261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}