cancel
Showing results for 
Search instead for 
Did you mean: 

RTC as wakeup-source on C0 family

Panda
Associate II

Hello,

 

I have found various guides on how to configure the RTC as wakeup-source. However, they do not seem to apply to the C0 family.

In the CubeIDE I cannot find the depicted settings on RTC, (most notably, no option to select internal wakeup and configure wakeup counter and clock)

 

Is this not implemented on the C0 family?

 

I just want my MCU to wake up from sleep mode every x milliseconds. What else can I do to implement this on a C011?

 

Thanks

Lucas

3 REPLIES 3
KnarfB
Super User

You can set a periodic RTC alarm to exit sleep mode or stop mode. For standby mode, you may use IWDG for periodic self-wakeup if the standfby period is reasonably small. Examples are in my C0 repository and register level guide: FrankBau/stm32c0 

hth

KnarfB

 

Ah, I wasn't aware that this existed.

Thank you, this is super helpful!

 

To clarify, I would like to use Stop Mode. So no need for IWDG I guess.

 

I guess that I can use the "rtc_alarm_irq - set a periodic RTC alarm interrupt, used to toggle a LED once per minute" project and build upon that. But instead of toggling the LED I return from Stop mode.

 

I am quite unexperienced in using sleep modes on stm32 MCUs. While I found some material about this (also was looking at your stop_uart project and the standby_iwdg project), I am still struggling to understand how to realize an implementation like this.

 

Can you lead me to any material regarding exiting stop mode from RTC interrupt that can push me in the right direction?

Thanks

Lucas

 

 

Let's switch from register level to a STM32CubeMX generated project using HAL.

Generate a new project, I used STM32C0116-DK for example with all default settings.

Activate a periodic RTC alarm once per minute, date and time don't matter.

KnarfB_0-1749619543458.png

The generated code will already activate that alarm in MX_RTC_Init();

Add code in main.c while loop:

  /* USER CODE BEGIN WHILE */
  while (1) {
    HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
    HAL_SuspendTick();
    HAL_PWREx_EnableInternalWakeUpLine();
    HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE);
    SystemClock_Config();
    HAL_ResumeTick();
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */

Build and run the code. The on-board LED will toggle once per minute.

For reference I have attached the .ioc file used for code generation.

For you own designs: make sure that the RTC runs on LSI clock.

hth

KnarfB