Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello,

I'm going to get an Interrupt Service Routine to handle a Function every second.
Sorry, I can't find any RTC ISR in "XMC1200.h"

What have I to do?

// Enable periodic seconds interrupt
RTC->MSKSR |= (((uint32_t)1U << RTC_MSKSR_MPSE_Pos) & RTC_MSKSR_MPSE_Msk);

Thanks and regards,
Bernd
0 Likes
8 Replies
Not applicable
Hi Bernd,

The RTC is using SCU.SR1 interrupt.

So after you enable the periodic interrupt, the interrupt will be trigger under SCU.SR1 interrupt node.
0 Likes
Not applicable
Thank you Jackson,

Where can I read and learn that?
0 Likes
Not applicable
Hi Bernd,

The information is available in the Interrupt Source table available in the Reference Manual under NVIC chapter.
0 Likes
Not applicable
Thank you Jackson,

You mean after:
RTC->MSKSR |= (((uint32_t)1U << RTC_MSKSR_MPSE_Pos) & RTC_MSKSR_MPSE_Msk);

I will get here an interrupt?

void SCU_1_IRQHandler(){
// To Do
}
Regards,
Bernd
0 Likes
Not applicable
Hi Bernd,

Yes, you should get the interrupt at
void SCU_1_IRQHandler()
0 Likes
Not applicable
Thank you very much for your help !!
Regards,
Bernd
0 Likes
Not applicable
Hi Jackson,

I assembled an external oscillator at my XMC1200 kid like the application note "DEV_XMC1000_Oscillator_Handling_v1_1."
I measured the oscillator and I have a signal of 32,7648kHz.
But I get no interrupt.

Could you help me?

void SCU_1_IRQHandler(){
//To Do
int8_t i = 0;
i++;
}

int main(void)
{
CMPCU_Init();
PORTS_Init();
SCU_Clock_Init();
CCU40_CC41_init();
ERU0_Init();

Init_RTC();
Enable_RTC_INTERRUPT();

while(1)
{

}
return 0;
}
void Init_RTC(void){
//Time in Format "xx:xx:xx"
char time[] = __TIME__;
int hours = atoi(time);
int minutes = atoi(&(time[3]));
int seconds = atoi(&(time[6]));
char date[] = __DATE__;
char month[3];
int i_month = 0;
month[0] = __DATE__[0];
month[1] = __DATE__[1];
month[2] = __DATE__[2];
if((month[0] == 'J')&&(month[1] == 'a')&&(month[2] == 'n')) i_month = 1;
if(month[0] == 'F') i_month = 2;
if((month[0] == 'M')&&(month[1] == 'a')&&(month[2] == 'r')) i_month = 3;
if((month[0] == 'A')&&(month[1] == 'p')) i_month = 4;
if((month[0] == 'M')&&(month[1] == 'a')&&(month[2] == 'y')) i_month = 5;
if((month[0] == 'J')&&(month[1] == 'u')&&(month[2] == 'n')) i_month = 6;
if((month[0] == 'J')&&(month[1] == 'u')&&(month[2] == 'l')) i_month = 7;
if((month[0] == 'A')&&(month[1] == 'u')) i_month = 8;
if(month[0] == 'S')i_month = 9;
if(month[0] == 'O')i_month = 10;
if(month[0] == 'N')i_month = 11;
if(month[0] == 'D')i_month = 12;

int day = atoi(&(date[3]));
int year = atoi(&(date[7]));

// Disable clock gating to RTC
SCU_GENERAL->PASSWD = PWopen; // disable bit protection
SCU_CLK->CGATCLR0 |= SCU_CLK_CGATCLR0_RTC_Msk;
SCU_GENERAL->PASSWD = PWclose; // enable bit protection

//Disable RTC
while(SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_RTC_CTR_Msk);
RTC->CTR &= ~RTC_CTR_ENB_Msk;

//Set time based on data structure (rtc_time)
while((SCU_GENERAL->MIRRSTS & (SCU_GENERAL_MIRRSTS_RTC_TIM0_Msk | SCU_GENERAL_MIRRSTS_RTC_TIM1_Msk)) != 0x0U);
RTC->TIM0 = ((uint32_t)seconds << RTC_TIM0_SE_Pos)
| ((uint32_t)minutes << RTC_TIM0_MI_Pos)
| ((uint32_t)hours << RTC_TIM0_HO_Pos)
| ((uint32_t)day << RTC_TIM0_DA_Pos);

RTC->TIM1 = (((uint32_t)i_month << RTC_TIM1_MO_Pos) | ((uint32_t) year << RTC_TIM1_YE_Pos));

//Enable RTC
while(SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_RTC_CTR_Msk);
RTC->CTR |= RTC_CTR_ENB_Msk;
}
//*********************************************************************************************************************************************************************************
void CMPCU_Init(void){
COMPARATOR->ANACMP0 = ((0x0 << COMPARATOR_ANACMP0_CMP_OUT_Pos) & COMPARATOR_ANACMP0_CMP_OUT_Msk) |
((0x0 << COMPARATOR_ANACMP0_CMP_LPWR_Pos) & COMPARATOR_ANACMP0_CMP_LPWR_Msk) |
((0x0 << COMPARATOR_ANACMP0_ACMP0_SEL_Pos) & COMPARATOR_ANACMP0_ACMP0_SEL_Msk) |
((0x0 << COMPARATOR_ANACMP0_CMP_HYST_ADJ_Pos) & COMPARATOR_ANACMP0_CMP_HYST_ADJ_Msk)|
((0x0 << COMPARATOR_ANACMP0_CMP_INV_OUT_Pos) & COMPARATOR_ANACMP0_CMP_INV_OUT_Msk) |
((0x1 << COMPARATOR_ANACMP0_CMP_FLT_OFF_Pos) & COMPARATOR_ANACMP0_CMP_FLT_OFF_Msk) |
((0x1 << COMPARATOR_ANACMP0_CMP_EN_Pos) & COMPARATOR_ANACMP0_CMP_EN_Msk);
}
//*********************************************************************************************************************************************************************************
void PORTS_Init(void){
PORT0->IOCR8 = ((0x0 << PORT0_IOCR8_PC11_Pos) & PORT0_IOCR8_PC11_Msk) |
((0x14 << PORT0_IOCR8_PC10_Pos) & PORT0_IOCR8_PC10_Msk) |
((0x0 << PORT0_IOCR8_PC9_Pos) & PORT0_IOCR8_PC9_Msk) |
((0x0 << PORT0_IOCR8_PC8_Pos) & PORT0_IOCR8_PC8_Msk) ;
}
//*********************************************************************************************************************************************************************************
void SCU_Clock_Init (void){
SCU_GENERAL->PASSWD = 0x000000C0UL;
SCU_CLK->CLKCR = 0x3FF10200; // Config SCU Clock
while((SCU_CLK->CLKCR)&0x40000000UL); // wait for VDDC to stabilize
SCU_GENERAL->PASSWD = 0x000000C3UL;
SCU_GENERAL->PASSWD = 0x000000C0UL;
SCU_CLK->CGATCLR0 |= 0x04; // Disable CCU4 Gating
while((SCU_CLK->CLKCR)&0x40000000UL); // wait for VDDC to stabilize
SCU_GENERAL->PASSWD = 0x000000C3UL;
}
//*********************************************************************************************************************************************************************************
void CCU40_CC41_init(void){
CCU40->GIDLC |= CCU4_GIDLC_SPRB_Msk; // Prescaler Run Bit Set
CCU40_CC41->INS |= 0x03;
CCU40_CC41->INS |= 0x90000; // Configures the Event 0 to be active on raising edges
CCU40_CC41->CMC |= 0x0090; // External Capture on Event 0
CCU40_CC41->TC = 0x1048; // Timer is cleared on a capture event
CCU40_CC41->INTE = 0x0100; // Event 0 interrupt
CCU40_CC41->SRS = 0x0100; // Interrupt is forward to CC4ySR0
NVIC_SetPriority(CCU40_1_IRQn, 20); // Configure NVIC for interrupt
NVIC_EnableIRQ(CCU40_1_IRQn);
}
//*********************************************************************************************************************************************************************************
void ERU0_Init(void){
ERU0->EXISEL &= 0xFFFC; // Event S0A from input 0A0
ERU0->EXICON[0] |= 0x0007; // Rising edge trigger, Output to OGU0
ERU0->EXOCON[0] |= 0x1024; // Enable event detection
}
//*********************************************************************************************************************************************************************************
void Enable_RTC_INTERRUPT(){
// Enable periodic seconds interrupt //SCU_1_IRQn = 1, /*!< SCU SR1 Interrupt
while(SCU_GENERAL->MIRRSTS & SCU_GENERAL_MIRRSTS_RTC_CTR_Msk);
RTC->MSKSR |= (((uint32_t)1U << RTC_MSKSR_MPSE_Pos) & RTC_MSKSR_MPSE_Msk);
}
0 Likes
Not applicable
I got it,

I forgot:

NVIC_SetPriority(SCU_1_IRQn, 0x00); //This CMSIS function configures node 1 to priority level 0 (highes Priority)
NVIC_ClearPendingIRQ(SCU_1_IRQn); //This function clears node 1 pending status
NVIC_EnableIRQ(SCU_1_IRQn); //This function enables node 1 for interrupt request generation

But the extern oscillator didn't work because the time is inaccurate.

What could be wrong?
0 Likes