我在前面找的一个例子,讲的是捕获
P1DIR &= ~BIT2; // P1.2 = (InputDirection + TA0.1) = CCIxA.1 --> CCR1
P1SEL|=BIT2;
TACCTL1 = CAP + CCIS_0 + CM_3 + CCIE; // Capture CCIxA, both edge, interrupt enable.
TACTL = TASSEL_1 + MC_2; // ACLK, continuous mode.
_EINT();
volatile unsigned int CCRx = 0;
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TAIV_ISR(void)
{
unsigned int interval;
if(TACCTL1 & CCIFG)
{
TACCTL1 &=~ CCIFG;
P1OUT ^= BIT0;
interval=CCR1-CCRx;
CCRx=CCR1;
}
}