Hi All,
This one took me a long time to figure out, and this MUST have a solution.
Readings are going to be taken 9 times per second, following an RTC interrupt. Despite what the Users Manual stated, the RTC interrupt must be cleared in the ISR routine. This is just a test routine. A volatile unsigned long integer is incremented by one. A very short length led blinks with the updated number on the LCD. Then LPM0 is invoked to wait for the next RTC interrupt.
The problem is that when P1.2 or P2.6 have their interrupts set in the IO init, this block of code fails completely. Ultimately, there are other interrupts like these which will have to run concurrently with the RTC in the final project. This needs a solution.
// Configure button S1 (P1.2) interrupt
GPIO_selectInterruptEdge(GPIO_PORT_P1, GPIO_PIN2, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN2);
GPIO_clearInterrupt(GPIO_PORT_P1, GPIO_PIN2);
// GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN2);
// Configure button S2 (P2.6) interrupt
GPIO_selectInterruptEdge(GPIO_PORT_P2, GPIO_PIN6, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2, GPIO_PIN6);
GPIO_clearInterrupt(GPIO_PORT_P2, GPIO_PIN6);
// GPIO_enableInterrupt(GPIO_PORT_P2, GPIO_PIN6);
...........
__bis_SR_register(LPM0_bits | GIE); // GO TO SLEEP
__no_operation(); // End of main loop
}
#pragma vector = RTC_VECTOR
__interrupt void RTC_ISR(void)
{
RTC_clearInterrupt(RTC_BASE, RTC_OVERFLOW_INTERRUPT_FLAG);
__bic_SR_register_on_exit(LPM0_bits); //edit, this now appears at the top of the ISR routine
P1OUT |= BIT0; // Turn LED1 On/
__delay_cycles(100000);
IReturn = IReturn+10;
P1OUT &= ~BIT0; // Turn LED1 off
__delay_cycles(100000);
}