cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't it enter when I press the button to enter standby mode?

easla.1
Associate II

I sleep at the time I set with rtc on the stm32f103c8t6 microcontroller. I wake up with the alarm I set. No problems so far. I want to sleep when I press a button. But when I press the button, it sleeps, then wakes up immediately and sets the alarm to 0:0:0. How is this possible? Why does he wake up right away?

if (sTime.Hours == 6 && sTime.Minutes == 59)

{

sAlarm.AlarmTime.Hours = 7;

sAlarm.AlarmTime.Minutes = 1;

sAlarm.AlarmTime.Seconds = 0;

sAlarm.Alarm = RTC_ALARM_A;

HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD);

}

if (sTime.Hours == 7 && sTime.Minutes == 0 && sTime.Seconds == 0)

{

HAL_PWR_EnterSTANDBYMode();

}

if (sTime.Hours == 7 && sTime.Minutes == 1)

{

sAlarm.AlarmTime.Hours = 7;

sAlarm.AlarmTime.Minutes = 3;

sAlarm.AlarmTime.Seconds = 0;

sAlarm.Alarm = RTC_ALARM_A;

HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD);

}

if (sTime.Hours == 7 && sTime.Minutes == 2 && sTime.Seconds == 0)

{

HAL_PWR_EnterSTANDBYMode();

}

BUTON_FLAG = HAL_GPIO_ReadPin(buton_GPIO_Port, buton_Pin);

if (BUTON_FLAG == 1)

{

HAL_PWR_EnterSTANDBYMode();

}

1 ACCEPTED SOLUTION

Accepted Solutions
easla.1
Associate II

__HAL_PWR_CLEAR_FLAG must be done before second HAL_PWR_EnterSTANDBYMode();

View solution in original post

2 REPLIES 2
easla.1
Associate II

__HAL_PWR_CLEAR_FLAG must be done before second HAL_PWR_EnterSTANDBYMode();

easla.1
Associate II

4 günümü almış aq