This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Which interrupt flag is used to enter TIMERA0_VECTOR , Whether CCIFG or TAIFG

Other Parts Discussed in Thread: MSP430F2491

Hi,

This is a basic doubt about TIMERA0_VECTOR. When does to control enter the TIMERA0_VECTOR. Is it when the CCIFG is set or when the TAIFG is set? Or is there any other way where one can define which of them to be used to execute TIMERA0 ISR.

  • You are not writing which MCU, but A0 is general for CCR0, and A1 for all other CCRx including TAIFG.
  • #include "msp430f2491.h"

    void main( void )
    {
      // Stop watchdog timer to prevent time out reset
      WDTCTL = WDTPW + WDTHOLD;
      P1DIR = 0x00;
      P1SEL = BIT1;
      P1IE  = BIT7;
      P1IES = BIT7;
      P4DIR = 0xFF;
      P4SEL = 0x00;
      P4OUT = 0X00;
    // Capture either edge of CCI0B , synchronized , interrupts enabled
    TACCTL0 = CM_3 | CCIS_1 | SCS | CAP | CCIE;
    // Start timer: ACLK , no prescale , continuous mode , no ints , clear
    TACTL = TASSEL_1 | ID_0 | MC_2 | TACLR;
    __enable_interrupt();
    __bis_SR_register(LPM0 + GIE);
    for (;;) { // Loop forever with interrupts
    __low_power_mode_3 (); // Only ACLK continues to run
    }
    }
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    {   
      P4OUT = 0X0F; // just to avoid confusion because of the ISR turn on the lower nibble led's
      //static unsigned int lastvalue =0;
     // P4OUT = lastvalue++;
    }
    #pragma vector = PORT1_VECTOR
    __interrupt void PORT1_VECTOR_ISR()
    {
      P4OUT ^=(7<<0) ;
      P1IFG = 0X00;
    }

    In the above program , actually I want to use CCIFG0 from the main function for generating the interrupt on capture. I am using a switch at TA0 (P1.1) and linking it with CCI0B at TACCTL0. The port 1 interrupt is working (when I press the switch P1.7 the led's at port 4 glows) in the above program but the timerA0_interrupt ISR is not being executed when I press the switch. Please let me know if anything is wrong in the code.

  • And in this program it seems the TAIFG by an overflow is generating TIMERA0_VECTOR . Can anyone tell me the difference please....

    #include "msp430f2491.h"
    #define LED_0 BIT0
    #define LED_1 BIT6
    #define LED_OUT P1OUT
    #define LED_DIR P1DIR
    unsigned int timerCount = 0;
    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    LED_DIR |= (LED_0 + LED_1); // Set P1.0 and P1.6 to output direction
    LED_OUT &= ~(LED_0 + LED_1); // Set the LEDs off
    TACCTL0 = CCIE;
    TACTL = TASSEL_2 + MC_2; // Set the timer A to SMCLCK, Continuous
    // Clear the timer and enable timer interrupt
    __enable_interrupt();
    __bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled
    }
    // Timer A0 interrupt service routine
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    {
    timerCount = (timerCount + 1) % 8;
    if(timerCount ==0)
    P1OUT ^= (LED_0 + LED_1);
    }
  • Bhanu Prakash said:
    And in this program it seems the TAIFG by an overflow is generating TIMERA0_VECTOR . Can anyone tell me the difference please....

    That example triggers TIMERA0_VECTOR when the CCIFG bit of TACCTL0 is set (same as the previous example). You can tell by the fact that CCIE in TACCTL0 is set, whereas the TAIE bit of TACTL is not set.

    Also, if TAIE was set the MCU would try to execute the TIMERA1_VECTOR, not the TIMERA0_VECTOR. That would be bad news as no ISR is defined for TIMERA1_VECTOR. As Leo already said in his answer, TIMERA0_VECTOR is only triggered by CCIFG being set in TACCTL0. All other interrupt flags for that timer module trigger TIMERA1_VECTOR instead.

  • The A0 vector is triggered by CCR0.CCIE. If hte iSR is called, the CCIFG bit is automatically cleared. For all other timer interrupts, the CCIE bits need to be cleared by software before exiting the ISR
    However, to make CCR0 capture a signal edge, you need to select the port pin for module usage (set PxSEL.y =1 for this pin). If you do, the normal I/O interrupt won't work on this pin anymore.

    Note that a PUC (e.g. triggered by WDT or violations), the timer registers are not reset. Previously active timers will still be counting, Interrupts are still pending and enabled and will call the ISR as soon as you set GIE, even if your code hasn't initialized the timers yet and doesn't expect the interrupts at this time.

**Attention** This is a public forum