0
\$\begingroup\$

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: enter image description here
  • 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)

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ Can you show the RTC->CRH and RTC->CRL registers value when HAL_RTC_AlarmIRQHandler is called? Perhaps some other RTC interrupt occurs. \$\endgroup\$
    – sx107
    Commented Sep 18, 2023 at 12:17
  • \$\begingroup\$ RTC -> CRH = 2, RTC -> CRL = 57 \$\endgroup\$ Commented Sep 18, 2023 at 12:46
  • \$\begingroup\$ You have not told how you set the alarm. Which HAL function you use? \$\endgroup\$
    – Justme
    Commented Sep 18, 2023 at 12:48
  • \$\begingroup\$ In the Cube method - MX_RTC_Init, there is a call - HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD) \$\endgroup\$ Commented Sep 18, 2023 at 12:52
  • \$\begingroup\$ That is weird, interrupt is on, but when it's called, the interrupt flag is reset. Isn't CNTL value also weird, by the way, if the alarm should be called on CNTL = ALRL? \$\endgroup\$
    – sx107
    Commented Sep 18, 2023 at 12:57

1 Answer 1

0
\$\begingroup\$

Chinese versions STM32F103C8T6 do not support Alarm :(

After I didn't get an answer here, I asked on some local groups. I was informed that this is not the first time this has happened and we have come to the conclusion that my BluePill boards are fake. There is no direct confirmation of this, only the possibly low price of these boards - $2.5 with delivery to Russia. In appearance and markings this is an original STM32 board - the full marking of the chip is "STM32 F103C8T6 991KA 93 MYS 808".

I would like someone to try and repeat the same example and confirm that everything was done correctly.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.