Hello everyone, I was wondering if someone could point me in the right direction. I'm trying to measure the period of a square wave signal, and the interrupt does happen but it never stops. It is supposed to stop when PWBuffer is filled but it keeps going. Here is my code:
unsigned int PWBuffer[10];
int main(void){
P2DIR &= ~BIT3;
P2SEL |= BIT3; //Select Timer Capture option
TACTL = TASSEL_2 + TACLR; //SMCLK = 1 Mhz, continuous mode
TACCTL1 = CM_1+CCIS_1+SCS+CAP+CCIE; //CCR1 used for timer capture
// capture on rising edge, CCIO
// Enable timer interrupt
Current_Edge_Time = 0x00;
Previous_Edge_Time - 0x00;
SC = 0;
TACTL |= MC_2; //Start Timer, Continuous mode
TACCTL0 |= CCIE;
_EINT();
}
Timer A1 interrupt service routine
#pragma vector = TIMERA1_VECTOR
__interrupt void TA1_ISR(void){
P1OUT ^= 0x01;
switch(_even_in_range(TAIV,10)) //Efficient switch-implementation
{
case 0: break;
case 2: //CCR1 capture interrupt
Current_Edge_Time = TACCR1;
if(Current_Edge_Time < Previous_Edge_Time){
buffer[SC++] = ((0xFFFF - Previous_Edge_Time) + Current_Edge_Time);
}
else
{
buffer[SC++] = Current_Edge_Time - Previous_Edge_Time;
}
Previous_Edge_Time = Current_Edge_Time;
if(SC > 10){
SC = 0;
_no_operation();
// _DINT(); this one didn't work
//TACCTL0 &= ~CCIE; this one didn't work
//CCTL0 &= ~CCIE; this one didn't work
}
break;
case 4: break; //CCR2 interrupt
case 6: break; //Reserved
case 8: break; //Reserved
case 10: break; //Timer Overflow
}
}