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.

TACCR0 vs. TACCR1



Hi:

I am new to MSP430 MCU and learning it using the launchpad I just purchased. I followed a example posted by Don Bindner at http://dbindner.freeshell.org/msp430/demo.html.

Here is part of the code I have questions with:

void PreApplicationMode(void) {

P1DIR |= RED_LED + GRN_LED;
P1OUT |= RED_LED;
P1OUT &= ~GRN_LED;


BCSCTL3 |= LFXT1S_2;

BCSCTL1 |= DIVA_1;

TACCR0 = 1200;

TACTL = TASSEL_1 | MC_1;
TACCTL1 = CCIE + OUTMOD_3;
TACCR1 = 600;

__bis_SR_register(LPM3_bits + GIE);
}

The code uses two TACCRs to set the number of counts. TACCR0 = 1200 sets the counter period while TACCR1 = 600 sets the interrupt. It seems to me that the TACCR1 would trigger the interrupt every 600 clock ticks which is shorter than the number of 1200 in TACCR0. However, my observation is that the value in TACCR0 determines how often the trigger would happen while the value in TACCR1 does not as long as it is less than the value in TACCR0.

Please kindly help and thanks in advance.

--Neo

  • Since the counting mode, MC, is 01, TAR counts from 0 up to 1200 (the value of CCR0) and back to 0, up to 1200, and repeat. Thus the period from TAR=0 to the next TAR=0 is 1201 clocks. The period from TAR=1 to the next TAR=1 is also 1201 clocks. So are the periods from 2 to next 2, from 3 to next 3, .. , from 600 to next 600, etc. 

  • I cannot reply

  • Hello,

    timer counts to value in TACCR0. When value is equal TACCR1 something happens.

    I could write here a lot but you can find nice description in: MSP430x2xx Family User's Guide (Rev. I)  available here: http://www.ti.com/product/msp430g2553 .

    TimerA section begins on page number 363. Look at page 371 for output modes description.

    Ask if something won't clear :)

    Best regards,

    Mikolaj

  • Hi QCY:

    Thanks you very much for the reply. This is very helpful.

    --Neo

  • Hi Mikolaj:


    Thanks allot. Now I understand that TACCR0 and TACCR1 have different structures and features. I will definitely do more readings.



    --Neo

  • Mikolaj Filar said:
    timer counts to value in TACCR0. When value is equal TACCR1 something happens.

    I want to add a few things:

    The timer can run in different modes. In up mode (or up/down mode), the timer counts up to the value of CCR0 and either rolls over to 0 then or counts down to 0. In these modes, CCR1..x will trigger interrupts at the same interval as CCR0 or timer overflow. The difference is the phase, the moment when the interrupts come in relation to the CCR0 interrupt.
    The main reason for these modes is the generation of PWM signals, where the frequency is static, but the moment when the output signal changes is important.

    The other mode the timer can use is the cont mode. In this mode, the  timer counts up form 0 to 65535 and rolls over then. CCR0 and CCR1..x are identical in this mode.
    However, setting a static value to CCRx will also result in equal intervals (of 65536 ticks) and only the moment of the interrupt in relation to the timer overflow changes. But in this mode, usually CCRx is changed on every interrupt. If you add e.g. 1000 to CCR0 on each CCR0 interrupt, the next interrupt will happen 1000 timer ticks after the last interrupt. Since you Can use a different value for each CCRx, each interrupt can have its own interval. (only problem is: if your ISR is delayed for some reason, so you add the delay value after the timer has already progressed so far, you won't get an interrupt until the next timer cycle)

**Attention** This is a public forum