2023-05-19 04:36 PM
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();
}
Solved! Go to Solution.
2023-05-22 02:28 PM
__HAL_PWR_CLEAR_FLAG must be done before second HAL_PWR_EnterSTANDBYMode();
2023-05-22 02:28 PM
__HAL_PWR_CLEAR_FLAG must be done before second HAL_PWR_EnterSTANDBYMode();
2023-05-22 02:28 PM
4 günümü almış aq