1

Playing around with the nucleo board g070 I'm trying to setup interrupt every seconds with the RTC's wakeup timer. However I did not find a corresponding interrupt in the header file(stm32g0xx.h) generated by CubeMX. I am trying to use only LL as I want to understand how to work with interrupts at a lower level. I set up the RTC as follows:

  LL_RTC_InitTypeDef RTC_InitStruct = {0};

  /* Peripheral clock enable */
  LL_RCC_EnableRTC();
  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_RTC);

  RTC_InitStruct.HourFormat = LL_RTC_HOURFORMAT_24HOUR;
  RTC_InitStruct.AsynchPrescaler = 127;
  RTC_InitStruct.SynchPrescaler = 255;
  LL_RTC_Init(RTC, &RTC_InitStruct);

  // Auto-wakeup interrupt configuration
  LL_RTC_DisableWriteProtection(RTC);
  LL_RTC_WAKEUP_Disable(RTC);
  while (LL_RTC_IsActiveFlag_WUTW(RTC) != 1);
  // Configure second wakeup timer
  LL_RTC_WAKEUP_SetAutoReload(RTC, 0x8000);
  LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
  LL_RTC_EnableIT_WUT(RTC);
  LL_RTC_WAKEUP_Enable(RTC);
  LL_RTC_SetAlarmOutEvent(RTC, LL_RTC_ALARMOUT_WAKEUP);
  LL_RTC_EnableWriteProtection(RTC);

Then I tried to setup the NVIC but could not find a corresponding IRQ in the IRQn_Type enum.

NVIC_SetPriority(?, 1);
NVIC_EnableIRQ(?);

Update:

It seems like the RTC_TAMP_IRQHandler doubles up as the wakeup interrupt(??). Setting the wakeup clock to LL_RTC_WAKEUPCLOCK_CKSPRE(or LL_RTC_WAKEUPCLOCK_CKSPRE_WUT) does not seem to work but if I use LL_RTC_WAKEUPCLOCK_DIV_16 then the interrupt occurs. To reset the interrupt I just have to clear the wakeup interrupt flag(??)

void RTC_TAMP_IRQHandler(void)
{
  LL_RTC_ClearFlag_WUT(RTC);
  LL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
}

Anyone can explain why it works like this?

2A-66-42
  • 554
  • 1
  • 5
  • 18
  • It is an EXTI interrupt. – 0___________ Sep 12 '20 at 19:47
  • Ok but which one? – 2A-66-42 Sep 12 '20 at 20:24
  • Read the Reference Manual – 0___________ Sep 12 '20 at 21:10
  • I did read it and found no reference to an EXTI interrupt related to RTC wakeup timer. Although in this doc (https://www.st.com/resource/en/application_note/dm00226326-using-the-hardware-realtime-clock-rtc-and-the-tamper-management-unit-tamp-with-stm32-microcontrollers-stmicroelectronics.pdf) I found something: `Wakeup alternate function output which can be routed to RTC_ALARM for RTC2 and TAMPALRM for RTC3 output (unique pad for alarm A, alarm B or Wakeup events) with configurable polarity.` But I still don't understand the point about the clock divider or the specific wakeup interrupt. – 2A-66-42 Sep 12 '20 at 21:57
  • Usually exti line 20. – 0___________ Sep 12 '20 at 22:14

0 Answers0