Accidental Double Interrupts on a Timer

 In embedded C, MSP430

I had a program where I was using a timer and an ISR to flip a bit on a TI MSP430.  Well, the bit would only filp for a few milliseconds and then revert back to its prior value.  As it turns out, I was calling the ISR twice every time I wanted it.

Here’s how it went down:

Originally when setting up the timer, I enabled the interrupt for the first capture and compare value, CCR0.

TACCTL0 = CCIE;        //Enabling CCR0 interrupt

I also enabled the timer interrupt,

TACTL |= TAIE;     //Enabling Timer_A0 Interrupt

I thought that the Timer_A0 interrupt had to be enabled for the CCR0 interrupt to work. Turns out, it is not so. With the timer counting in up mode, it would throw two interrupts. Removing the code that sets TAIE solved that problem.

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search