I have an application that makes use of a lot of peripherals, including a timer that calls a handler at periodic intervals. If there is no watchdog reset, everything runs as expected.
If I comment out the code to feed the watchdog, the rest occurs after the expected delay, but the MSP430 does not appear to really be doing a "full" reset of the timer peripheral. After the watchdog reset, TA0_TA0CCTL0 contains a value of 0x01. This indicates that the timer interrupt (TAIE) flag has properly been cleared, like it should, but the interrupt flag (TAIFG) is set, indicating a pending interrupt!
What can I do to clear all interrupts that could have been pending/active before the watchdog reset, so that my interrupt handlers cannot execute before application initialization?
Pseudocode:
void main() { // (Never reaches here after a watchdog reset) // Initialize application data (pointer initialization, heap allocation, etc...) // Initialize watchdog ROM_WDT_A_initWatchdogTimer(WDT_A_BASE, WDT_A_CLOCKSOURCE_SMCLK, WDT_A_CLOCKDIVIDER_8192K); ROM_WDT_A_start(WDT_A_BASE); // Initialize other peripherals, including a hardware timer for (;;) { // Feed watchdog ROM_WDT_A_resetTimer(WDT_A_BASE); } } void timerInterruptHandler() { // Accesses application data, which must be initialized before this is called, or the application crashes }