I understand my problem may be strictly hardware related, but the inconsistent behavior has me wondering if there is a software issue.
I am using a reed switch and a capture input. The reed switch has been debounced to the best of my knowledge. I have attached a picture of the circuit below.
The setting for the capture input are as follows.
void timer1AInit (void)
{
// **** TIMERA1 CONTROL ****
TA1CTL = TASSEL_1 + MC_1 + TACLR;
// *** CHANNEL 0 ****
TA1CCR0 = 30000;
//**** CHANNEL 0 CONTROL ****
TA1CCTL0 = CCIE;
// **** CHANNEL 1 CONTROL ****
TA1CCTL1 = CM_2 + CCIS_0 + SCS + CAP + CCIE;
}
I am having two issues.
1. I periodically have switch bounce at the end of the capture. The input is held high and when the capture takes place it is grounded. As the capture ends and the input goes back to high, I will get a number of captures but very rarely.
2. If the capture takes a long period of time, there is a double capture in the middle of the capture. I believe what is happening is that the ISR finishes before the capture ends, which clears the interrupt. When this happens the capture records again. I could be wrong and this may also be switch bounce related. I have attached a screen shot from a logic analyzer. The line of interest is line four. The first three captures show the double capture. The last group of captures is when the speed of the captures increases.
As a final thought, if I toggle an LED each time a capture occurs the toggling gets out of sync. It seems to work when the captures are slow but misses every fourth when the speed increases. I am confused, because I can see the capture working but it seems the ISR is not getting called. The LED is on line 3 and the captures are on line 4.
Any insight would be greatly appreciated.
Take care,
Jon