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?