I have a problem: I can’t get the alarm clock to work on the BluePill board. I need to get an interrupt to wake up the chip from Stop mode. It seems to me that the problem is in my BluePill board, here's what I do on a pure CubeIDE project (minimally reproducible example):
- I create a new project, select STM32F103C8T6, STMCube version FW_F1_V1.8.5 and configure it as follows:
- System Core - SYS - Debug - SerialWire
- System Core - RCC - HSE - Crystal/Ceramic Resonator
- System Core - RCC - LSE - Crystal/Ceramic Resonator
- Timers - RTC - Activate Clock Source
- Timers - RTC - RTC OUT - RTC Output on the Tamper pin
- Timers - RTC - Parameter Settings - Alarm A - Seconds 20
- Timers - RTC - NVIC Settings - RTC alarm interrupt through EXTI line 17 - Enabled
- Clock configuration:
- Add next code in main.c (/* USER CODE BEGIN 4 */ block):
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
// Reset RTC
MX_RTC_Init();
}
- Add break point in HAL_RTC_AlarmAEventCallback - MX_RTC_Init();
- And run debug
I expect this method to be called after 20 seconds, but it never gets called. Please tell me what am I doing wrong?
What I have already checked:
- The clock has started and is working. HAL_RTC_GetTime get the correct time.
- HAL_RTC_AlarmIRQHandler is called after 20 seconds, but does not trigger the interrupt callback due to the condition, why?:
if (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAF) != (uint32_t)RESET)