Skip to main content
Emm1592
Associate II
April 21, 2019
Question

How to wake up from stop mode with alarm A?

  • April 21, 2019
  • 1 reply
  • 1130 views

Hello,

I'm trying to wake up from stop 1 with the alarm A, and I was wondering if someone can help me with this.

Here is my code (I'm using HAL libraries first, the "easy" way base on the example ST gives: PWR/STOP1_RTC):

...

int main(void){

GPIO_InitTypeDef GPIO_InitStruct;

 HAL_Init();

BSP_LED_Init(LED2); 

SystemClock_Config(); //Config RCC

__HAL_RCC_PWR_CLK_ENABLE();

  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);

SystemPower_Config(); //Config the RTC ----> 19:50:00

setAlarmA(); // The alarm is set to: 19:51:00

while(1){

...

  /* Disable all used wakeup source */

HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);

/* Re-enable wakeup source */

HAL_RTCEx_SetWakeUpTimer_IT( ........?........);

/* Enter STOP 1 mode */

 HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);

} //End while (1)

} // End main

I don't know how to tell my STM that it will be woken up by the Alarm A (It goes there in the line I highlighted?) How do I do that?

My idea is to wake up the system at 19:51:00 and re-set the alarm A to: 19:52:00. In the alarmA callback, I wrote the following:

void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc){

setNewAlarmA();

}

I'm using the Nucleo Board STM32L476RG

Thank you very much for all the help.

This topic has been closed for replies.

1 reply

Jack Peacock_2
Associate II
April 22, 2019

RTC Alarm is not a timer per se. Alarm A/B uses the RTC EXTI18 external interrupt, so EXTI18 must be enabled on rising edge to wake from STOP mode, for the NVIC vector in the configuration. Don't use the HAL, no idea how it handles EXTIs, but I use alarm B for something similar. RTC must be running in STOP mode with LSE or LSI clock on.

Jack Peacock