Hi,
I tested the below simple code on S32K144 EVB.
The RTC second interrupt toggles Blue LED every second while the Alarm interrupt toggles Red LED every 4 second.
It uses 32KHz LPO_CLK.
void RTC_init(void)
{
SIM->LPOCLKS |= (1 << 3) | (1 << 4);
PCC->PCCn[PCC_RTC_INDEX] = PCC_PCCn_CGC_MASK;
RTC->SR &= ~(1 << 4);
RTC->CR &= ~(1 << 7);
RTC->IER &= ~(0b111 << 16);
RTC->IER |= (1 << 4) | (1 << 2);
RTC->TSR = 0x00000000;
RTC->TAR = 4;
RTC->CR |= (1 << 24);
S32_NVIC->ICPR[1] = (1 << (46 % 32));
S32_NVIC->ISER[1] = (1 << (46 % 32));
S32_NVIC->IP[46] = 0x00;
S32_NVIC->ICPR[1] = (1 << (47 % 32));
S32_NVIC->ISER[1] = (1 << (47 % 32));
S32_NVIC->IP[47] = 0x10;
RTC->SR |= (1 << 4);
}
void port_init(void)
{
PCC-> PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK;
PTD->PDDR |= (1 << 0);
PORTD->PCR[0] = 0x00000100;
PTD-> PSOR |= (1 << 0);
PTD->PDDR |= (1 << 15);
PORTD->PCR[15] = 0x00000100;
PTD-> PSOR |= (1 << 15);
PORTD->PCR[13] |= PORT_PCR_MUX(7);
}
void RTC_Seconds_IRQHandler(void)
{
PTD->PTOR |= (1 << 0);
}
void RTC_IRQHandler(void)
{
PTD->PTOR |= (1 << 15);
uint32_t tar = RTC->TAR;
RTC->TAR = tar + 4;
}
int main(void)
{
port_init();
RTC_init();
while(1){
}
}
Regards,
Daniel