Hi
I am using comparator to detect 16kHz signal at CA0 compared with 0.5Vcc. I can see CAOUT signal accordingly which verifies that comparator is working fine. Now I want to use timer in capture mode to read the pulse duration (CCI1B internal) I configured the comparator and timer module as following but I am unable to store the timer values. Please guide me
P6OUT = 0x00;
CACTL1 = CARSEL+CAREF_2; // Comp. A Int. Ref. enable on CA1 Comp. A Int. Ref. Select 2 : 0.5*Vcc
CACTL2 = P2CA0+CAF+CAOUT; // Comp. A Connect External Signal to CA0
CACTL1 |= CAON+CAIE ;
I am not sure about timer configuration
TACTL = TASSEL_2 + ID_0 + MC_2; // Use SMCLK (1 MHz Calibrated), no division, continuous mode
TACCTL1 = CCIS_1 + CAP + CCIE + SCS +CCI ; // Use CAOUT for input, synchronize, set to capture mode, enable interrupt for TA1.
// NOTE: Capturing mode not started.
TACCTL1 |= CM_2; // start TA1 capture on falling edge.
#pragma vector = TIMERA1_VECTOR
__interrupt void TA1_ISR(void) {
if (TAIV==0x02)
{
time=TACCR1;
printf("%d TACCR1", time); // this always print time=0
TACCTL1 &= ~(CM_2 + CCIFG + CCIE); // Stop TA1 captures, clear interrupt flag.
TACTL &= ~MC_2; // turn off TA.
P6OUT = 0x01; // Done measuring
count++;
}
Any guidance would be helpful.