Skip to main content
Gvenk.482
Visitor II
October 26, 2019
Question

STM32G070 Internal RTC Wake Up Interrupt hangs. After few iterations rtc wake up interrupt is hangs. Help will be appreciated.

  • October 26, 2019
  • 0 replies
  • 516 views

  if(low_power_mode == 1)

  {

    standby(10);

    HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);    

  }

void standby(int seconds) 

{

 /* Clear all related wakeup flags*/

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);

  rtc_set_wake_up_timer_s(seconds);

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);

}

void rtc_set_wake_up_timer_s(uint32_t sec)

{

  uint32_t clock = RTC_WAKEUPCLOCK_CK_SPRE_16BITS;

  // HAL_RTCEx_SetWakeUpTimer_IT will assert that delta is 0xFFFF at max

  if (delta > 0xFFFF) {

    delta -= 0x10000;

    clock = RTC_WAKEUPCLOCK_CK_SPRE_17BITS;

  }

  hrtc.Instance = RTC;

  HAL_StatusTypeDef status = HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, delta, clock);

  if (status != HAL_OK) {

    // debug("Set wake up timer failed: %d\n", status);

    NVIC_SystemReset();

   }

}

This topic has been closed for replies.