I'm new to the MPS430 and I'm trying to get started with timers.
I'd like to measure the time between two rising edges of a signal connected to P2.0 with timer A1.
I also have to blink a bunch of LEDs with timer A0.
This is what I have to initialize the timers:
P2DIR &= ~BIT0; //P2.0 Input
P2SEL |= BIT0; / Set P2.0 to Primary Peripheral function
TA1CCTL1 = CM_1 + SCS + CCIS_0 + CAP + CCIE; //Capture on rising edge of P2.0
TA1EX0 = TAIDEX_3; //Divide clock input by 4
TA1CTL = TASSEL_2 + MC_2 + ID_3; //SMCLK, continuous, divide by 8
TA0CCTL0 = CCIE; // CCR0 interrupt enabled
TA0EX0 = TAIDEX_3; //Divide clock input by 4
TA0CTL = TASSEL_2 + MC_2 + ID_3; // SMCLCK div 8, Continuous
__enable_interrupt();
This timer A0 interrupt to flash the LEDs
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{ //flash leds here }
and this one for timer A1
#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer0A1(void)
{
TA1CTL |= TACLR;
P1OUT ^= 0x01; //just toggling an LED for test
}
I'm confused about what pragma vector to use. The datasheet talks about timer a and b, but the vectors are timer0 and timer1 with Ax.
Am I configuring timer A1 correctly to trigger a capture on the rising edge of P2.0?
What pragma vector should I use for A1, and what value of TA1IV should I check in the interrupt to know an edge occurred?
Thanks in advance,
Paul.