Hello,
I am trying to generate an interrupt using the counter mode of the RTC approximatly every 10 seconds. Currently, my code looks like this:
RTCCTL0_H = RTCKEY_H; // Unlock RTC RTCPS0CTL |= RT0PSHOLD; RTCPS1CTL |= RT1PSHOLD; RTCCTL0 = RTCTEVIE; RTCCTL1 = RTCHOLD; // RTCPS0CTL = Real-Time Clock Prescale Timer 0 RTCPS0CTL = RT0PSDIV_7; // ACLK, /256 // RTCPS1CTL Register = Real-Time Clock Prescale Timer 1 Control Register RTCPS1CTL = RT1SSEL1 | RT1PSDIV_7 | RT1IP_1 | RT1PSIE; // out from RT0PS (Prescale 0), /256, Interrupts every /4 tick (every 10 sec) RTCPS0CTL &= ~(RT0PSHOLD); RTCPS1CTL &= ~(RT1PSHOLD); RTCCTL1 &= ~(RTCHOLD); __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 mode with interrupts enabled __no_operation();
However, I currently am a bit lost on how to achieve this. By dividing the 32kHz clock by 256 in RTCPS0CTL, I get the frequency down to 125Hz. By further dividing through 2 in RTCPS1CTL I get the frequency down to 0,48Hz. Then, I wanted to cause an interrupt every quarter tick (using RT1IP_1). This should cause an interrupt approximatly every 10 seconds. However, I'm not getting the expected interrupts - I get one approximatly one interrupt every second. Is there anything I mised? Could anyone point me in the right direction for this?
Thanks already!
EDIT:
The issue im having is, that I'm only getting RTCIV_RTCRDYIFG interrupts using this handler:
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(RTC_VECTOR))) RTC_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(RTCIV, 8)) { case RTCIV_NONE: // No interrupts break; case RTCIV_RT1PSIFG: // RTC prescaler 1 interrupt <-- our interrupt! __no_operation(); break; case RTCIV_RTCOFIFG: // OSC fault break; case RTCIV_RTCTEVIFG: // RTC Interval Timer break; case RTCIV_RTCAIFG: // RTC user alarm timer break; default: break; } }