Part Number: MSP430G2553
Hi all,
Can someone show me a simple example of using TimerA0_3 in CAP mode? As described in x2xx Family User Guide 12.2.4, I want to do speed computation. I'm not quite sure how to handle the interrupt.
This is the code I have so far. I want to trigger an interrupt upon CCIS.
// Use P1.6 output into Capture CCIS TimerA0_3
// MSP430G2xx3
// -----------------
// | |-
// | |
// ->|P1.1/CCI0A |-
// | | |
// | | P1.6|--
// | |
// |_______________________|
//
//******************************************************************************
#include <msp430.h>
volatile int count;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
TA0CTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, Up mode
TACCTL0 = CAP + CM_1 + CCIE; // CAP, Int. Enabled
P1SEL |= BIT1; // TA0.CCI0A
P1DIR |= BIT6; // pulse gen. into CCIS
__bis_SR_register(GIE);
while(1){
P1OUT ^= BIT6; // see how many cycles TAR incremented
}
}
// Timer_A3 Interrupt Vector (TA0IV) handler
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A1_VECTOR
__interrupt void Timer_A(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A1_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
switch( TA0IV )
{
case 2:
count++;
break; //
case 4: break; // CCR2 not used
case 10: // not used
break;
}
}
thank you,
Scott