Part Number: MSP430F5342
Other Parts Discussed in Thread: MSP430WARE
Hello,
I started with the MSP430F534x_compB_06.c example code included in the MSP430ware_1_60_02_09 package. (I don't know if that's current, but it seemed to work for my tests). I am trying to add timer capture on comparator output to my application and wanted to work through the example first to undestand the peripherals. Further, in my application, I'm already using Timer_A0 and Timer_A1 for other things so I wanted to use Timer_A2 for this function. In my application, I only care about capturing the timer count on rising edges. So, I modified the code to use the Timer_A2 only instead of Timer_A0 and Timer_A1. When I did this, I was seeing totally random values reported from the TA2CCR1. I modified my code again to switch back to try using Timer_A0 and the TA0CCR1 gave very consistent and expected results. I modified the code again to use Timer_A1, and again the TA1CCR1 was returning consistent and expected results. I then modified the code to enable all three timers at the same time, each with their respect interrupt handlers to record the values of TAxCCR1 values when the capture interrupts triggered. I found TA0CCR1 and TA1CCR1 were consistent but TA2CCR1 was still returning random values. I've looked for errata on this, but was not able to find any.
Here is how I set up the timers:
TA0CTL = TASSEL_2 + MC_1; // SMCLK, upmode
TA1CTL = TASSEL_2 + MC_1; // SMCLK, upmode
TA2CTL = TASSEL_2 + MC1;
TA0CCR0 = 0xFFFF;
TA1CCR0 = 0xFFFF;
TA2CCR0 = 0xFFFF;
TA0CCTL1 = CM_1+SCS+CAP+CCIS_1+CCIE; // Capture Rising Edge, Enable Interrupt
TA1CCTL1 = CM_1+SCS+CAP+CCIS_1+CCIE; // Capture Rising Edge, Enable Interrupt
TA2CCTL1 = CM_1+SCS+CAP+CCIS_1+CCIE; // Capture Rising Edge, Enable Interrupt
In their respective interrupt routines, for TAxIV == 2, I read the TAxCCR1 values and save it. For TA0 and TA1, I get consistent values of 984 and 951 respectively. I believe the slight difference in time has to do with interrupt latency and "resetting" the count values. For TA2, the value returned in TA2CCR1 is totally random.
Any idea what may be going on here? I can modify my original application to use TA2 where I had been using TA1 and then use TA1 for the comparator capture function, but I would really rather just introduce this new function on TA2 if possible.
Thanks in advance for any insight you may have on this.
Best regards,
Chris Ingraham