Jan 21

Accidental Double Interrupts on a Timer

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.

Permanent link to this article: http://blog.curioussystem.com/2011/01/accidental-double-interrupts-on-a-timer/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>