I'm using an interrupt to wake the microcontroller once the value has been reached. I see that in the Capture/Compare Control Register there is a Capture Overflow bit. I can't seem to find an example of checking for this bit once the value has been reached. One example interrupt looked like:

#pragma vector = TIMERA0_VECTOR
__interrupt void CCR0_ISR(void) {
    if (++i == 120) {
        P1OUT ^= RLY1;
} // CCR0_ISR

But this doesn't check the value of the bit. So how do i check to see if the timer has overflowed?

  • \$\begingroup\$ Presumably the rest of the example sets the timer into a mode where overflow is the only interrupt event. So, if the timer didn't overflow you didn't get to this code. \$\endgroup\$ – user_1818839 Feb 1 '13 at 14:10
  • \$\begingroup\$ could you please tell wat your exact output was?? \$\endgroup\$ – sheetansh Feb 1 '13 at 15:19

Not sure exactly which series MSP you're using so you'll have to look up the specifics. But the basic premise should apply across the board I think.

The following example is from the file msp430g2xx1_ta_03.c in the code snippets that can be downloaded from the TI Wiki:

#include <msp430.h>

int main(void)
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= 0x01;                            // P1.0 output
  TACTL = TASSEL_2 + MC_2 + TAIE;           // SMCLK, contmode, interrupt

  _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt

// Timer_A3 Interrupt Vector (TAIV) handler
#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A(void)
 switch( TAIV )
   case  2: break;                          // CCR1 not used
   case  4: break;                          // CCR2 not used
   case 10: P1OUT ^= 0x01;                  // overflow

The key is checking the TAIV register to see what caused the interrupt. Take a look at page 416 of the CC430 Family User's Guide:

TAIV Register Description

Now the code example is looking for a value of 10 in the TAIV register and the User Guide indicates that 0x0E is the overflow. So, again, check your specific chip's documentation. But the TAIV register is what will tell you what the cause of the interrupt is.


There are 2 interrupt sources for Timer A

  1. Timer Overflow #pragma vector = TIMERA0_VECTOR
  2. Capture/compare interrupt #pragma vector = TIMERA1_VECTOR

Interrupt routine you are looking will be executed when timer overflows and not when compare register is matched with TAR. You should use check TAIV register in

    #pragma vector = TIMERA1_VECTOR
__interrupt void CCR0_ISR(void) 
 //check TAIV for compare/capture interrupt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.