#include <msp430x14x.h>
unsigned int new_cap=0;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
for (i=0; i<5000; i++); // Delay for crystal stabilization
P1DIR = 0x01; // Set P1.0 out,1.1 input dir
P1SEL = 0x02; // Set P1.1 to TA0
CCTL0 = CM_1 + CCIS_0 + CAP + CCIE; // Rising edge + CCI0A (P1.1)
// + Capture Mode + Interrupt
TACTL = TASSEL_3 + MC_1; // SMCLK + Continuous Mode
_BIS_SR(GIE); // LPM0 + Enable global ints
while(1){
for (i=0; i<50000; i++)
P1OUT &= ~0x01; // LED off
for (i=0; i<50000; i++)
P1OUT |= 0x01;
}
_BIS_SR(LPM0_bits + GIE); // LPM0 + Enable global ints
}
#pragma vector=TIMERA0_VECTOR
__interrupt void TimerA0(void)
{
new_cap = TACCR0;
}