This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm using TA1 in capture mode with external capture pins driven by a PWM signal at 32.768 kHz. The CCIFG of TA1CCR0 never gets set, but I still get in the timer interrupt. One interrupt out of two, COV gets set, as if I skipped reading TA1CCR0. Here's my code:
void main(void) { // TA1.0 P3SEL |= BIT1; P3DIR&= ~BIT1; // TA1CLK P3SEL |= BIT0; P3DIR &= ~BIT0; TA1CTL = TASSEL__TACLK | ID__1 | MC__STOP; TA1CCTL0 = CM1 | CM0 | CAP; TA1R = 0; TA1CCTL0 &= ~COV; TA1CCTL0 |= CCIE; TA1CTL |= MC__CONTINOUS; } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) || defined(__CROSSWORKS__) #pragma vector=TIMER1_A0_VECTOR __interrupt void isr_timer1_a0(void) #elif defined(__GNUC__) && (__MSP430__) void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) isr_timer1_a0(void) #endif { if (TA1CCTL0 & CCIFG) { if (!((P3IN & BIT1) == BIT1)) { /* Do something */ } else { /* Do something else */ } } else if (TA1CCTL0 & COV) { TA1CCTL0 &= ~COV; /* Do something */ } }
I put a breakpoint in the interrupt and the value of TA1CCR0 keeps increasing, but the CCIFG flag is never set. Am I missing something?
Thanks,
Fred
Hi Fred,
I'm glad to see that your question has already be answered.
The capture mode is explained and visualized in Section 17.2.4 of the Family User's Guide (SLAU208 for the device you are currently looking at) and describes both when the CCIFG is set and also in what case the COV Bit is set. You can have a look for further reference.
Please feel free to comment in case there are other open points.
Best regards,
Britta
Thank you both,
Indeed, it's by looking at Figure 17-11 that I realized that my CCIFG interrupts must work if COV gets set. I just hadn't read the sentence "The TAxCCR0 CCIFG flag is automatically reset when the TAxCCR0 interrupt
request is serviced." from SLAU208.
Have a great day,
Fred
**Attention** This is a public forum