cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WLE RTC AlarmA for wake-up from Standby

OM
Associate II

Hi ,

I need  for my applicetion two maner of wake-up from Standby mode. One is regular wake up every one hour and second is asynchronous wake up by external signal. I have used WKUP1 signal on  PA0 input for external wake up. It is working corectly on rising edge. Regular wake up I want to realize by RTC AlarmA.  

I use function for AlarmA set:

void RTC_SetAlarmABin(uint32_t alarmTime) // Set next WakeUp time by number of seconds of day (0 - 86400)
{
RTC_AlarmTypeDef sAlarm;

sAlarm.AlarmTime.Hours = alarmTime / 3600;
sAlarm.AlarmTime.Minutes = (alarmTime % 3600) / 60;
sAlarm.AlarmTime.Seconds = (alarmTime % 3600) % 60;
sAlarm.AlarmTime.SubSeconds = 0;
sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY; // 0x8000 0000 it does not matter on week day
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
sAlarm.AlarmDateWeekDay = 1;
sAlarm.Alarm = RTC_ALARM_A;
HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN);

} //RTC_SetAlarmABin()

And Interrupt routine is

void RTC_Alarm_IRQHandler(void)
{
/* USER CODE BEGIN RTC_Alarm_IRQn 0 */

/* USER CODE END RTC_Alarm_IRQn 0 */
HAL_RTC_AlarmIRQHandler(&hrtc);

/* USER CODE BEGIN RTC_Alarm_IRQn 1 */

/* USER CODE END RTC_Alarm_IRQn 1 */
}

My testing code  to go to Standby mode is:


PWR_SetWKUP1Pin();              // function for setting of WKUP pin PA0
test1 = RTC_ReadRealTimeBin(&hrtc);  // read real time
RTC_SetAlarmABin(test1 + 20);             // set RTC Alarm A for 20 second from now

PWR_Enter_StandbyMode();               // enter to Snadby mode

When I do external wake up on pin PA0 or reset by NRST pin, the program starts corectly through reset procedure. When I wait for AlarmA wake up the program doesn't start corectly, but cpu is runing. I can check it by consumption. When correct program is running, input current is around 350mA (i use LED flashing indication). In Standby mode is imput current 2.5uA and when AlarmA bring about wake up, input current rise to 325mA. From this state it is not posible rescuse program by NRST signal reset. Solution is only make power down and starts power up. 

Do you know where is problem? Do you have en example how to handle RTC Alarm for wake up correctly?

I have the same solution with CPU STM32L071 without problem.

Thank you for your help.

 

 

 

1 REPLY 1
OM
Associate II

I did fault in input current. It is 3.50mA and 3.25mA. Thank you for understanding.