i use RTC to generate an ALARM. i have a function that sets the values of ALHOUR and ALMIN. after doing that i call a function (see below) that handles the interrupt initialization. immediately when i call this function an interrupt is generated even though time condition is not matched. when time condition is matched interrupt is not asserted.
/***************************/ /* Init ALARM */ /***************************/ void ALARM_init (void) { RTC_AMR = 0xFF; //Mask all bits RTC_AMR &= 0xF9; //enable MIN,HOUR /* Setup the VIC */ VICIntEnClr |= 1<<13; // clear 13th bit (is the RTC) VICVectAddr13 = (unsigned long int) &start_ALARM_ISR; VICVectCntl13 = 0x07; // Interrupt priority VICIntEnable |= 1<<13; //enable RTC interrupt, 13th bit return; } /***************************/ /* ALARM ISR */ /***************************/ void start_ALARM_ISR (void) __irq {
Hi Tamir, thanks for your response. where do you take this information from? i'm using the LPX236X user manual and under the RTC chapter i can't find anything you're writing about. even in my LPC23xx.h file there is no RTC_CR register. and your guess is right, i'm using the ARM7 LPC2368.
It comes from AN1780 available at http://www.st.com, titled "STR71X REAL TIME CLOCK APPLICATION EXAMPLE". It is possible that your LPC requires another procedure, though.
Here is what LPC23xx user manual says:
The RTC is configured using the following registers: 1. Power: In the PCONP register (Table 4-46), set bits PCRTC. Remark: On reset, the RTC is enabled. 2. Clock: Select clock source in Table 26-492. If the peripheral clock is selected, select PCLK_RTC in the PCLK_SEL0 register (Table 4-39). For the RTC, the peripheral clock must be scaled (see Section 26-10). 3. Interrupts: See Section 26-6.1 for RTC interrupt handling. Interrupts are enabled in the VIC using the VICIntEnable register (Table 70-71).
Hi Tamir thanks again.the LPC is much more comfortable to configure than the example you found. i'm familiar with the part you cut from the LPC user manual and i program accordingly. anyhow, in my application the RTC works fine, the problem is with the alarm. as i explained before the interrupt is asserted immediately after i call the function that suppose only to set the interrupt parameters even though the time condition is not matched. nonetheless while time condition is matched no interrupt is asserted.
I have not used the alarm function of the RTC, just the time keeping.
Might the uninitialized registers have created a false match directly when you powered up the RTC and that gets trigged as sonn as you enable interrupts?
When you get your spurious interrupt: Are you acknowledging it, to make sure that you may get a new interrupt at the actual alarm time?