cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L475RE. RTC Wake Up doesn't interrupt

JosepM Ribera
Associate III

Hi everyone!

I'm using STM32L475 and I have a problem, the RTC Wake Up doesn't interrupt.

I've set up the RTC in order to interrupt as follows (interrupt every 31.25 ms):

static void MX_RTC_Init(void)
{
 
  /* USER CODE BEGIN RTC_Init 0 */
 
  /* USER CODE END RTC_Init 0 */
 
  RTC_TimeTypeDef sTime = {0};
  RTC_DateTypeDef sDate = {0};
 
  /* USER CODE BEGIN RTC_Init 1 */
 
  /* USER CODE END RTC_Init 1 */
  /** Initialize RTC Only 
  */
  hrtc.Instance = RTC;
  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
  hrtc.Init.AsynchPrediv = 127;
  hrtc.Init.SynchPrediv = 255;
  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
  if (HAL_RTC_Init(&hrtc) != HAL_OK)
  {
    Error_Handler();
  }
 
  /* USER CODE BEGIN Check_RTC_BKUP */
    
  /* USER CODE END Check_RTC_BKUP */
 
  /** Initialize RTC and set the Time and Date 
  */
  sTime.Hours = 0x0;
  sTime.Minutes = 0x0;
  sTime.Seconds = 0x0;
  sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
  sTime.StoreOperation = RTC_STOREOPERATION_RESET;
  if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
  {
    Error_Handler();
  }
  sDate.WeekDay = RTC_WEEKDAY_MONDAY;
  sDate.Month = RTC_MONTH_JANUARY;
  sDate.Date = 0x1;
  sDate.Year = 0x0;
 
  if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
  {
    Error_Handler();
  }
  /** Enable the WakeUp 
  */
	
  if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 511, RTC_WAKEUPCLOCK_RTCCLK_DIV2) != HAL_OK)
  {
    Error_Handler();
  }

I'm using the LSE clock and it's working fine (the LSEON bit in RCC_BDCR register is "on").

The global interrupts are active:

/* RTC_WKUP_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);

Also the registers CR_WUTIC and CR_WUTIE (wake up timer interruption enable) are correctly ON.

However, it's never entering here (I'm checking in debug mode):

void RTC_WKUP_IRQHandler(void)
 
{
 
 /* USER CODE BEGIN RTC_WKUP_IRQn 0 */
 
 
 /* USER CODE END RTC_WKUP_IRQn 0 */
 
 HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);
 
 /* USER CODE BEGIN RTC_WKUP_IRQn 1 */
 
 
 /* USER CODE END RTC_WKUP_IRQn 1 */
 
}

What could be the issue? Why RTC Wake Up doesn't interrupt?

For more information, on the other side, the Systick interuption is working fine.

Thank you in advance

This discussion is locked. Please start a new topic to ask your question.
0 REPLIES 0