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.

continous mode

The continuous mode can be used to generate independent time intervals and output frequencies. Each
time an interval is completed, an interrupt is generated. The next time interval is added to the TAxCCRn
register in the interrupt service routine.

 

i didnt get the meaning of this.... pls help....

  • If you look at the Timer_A descriptions in the MSP430 Family User's Guide, you will see that in "continuous mode", the timer's counter (TAR) continuously counts from 0x0000 to 0xFFFF, resets to back to 0x0000 and counts up to 0xFFFF again over and over.

    While the counter (TAR) is counting, the comparators CCR0 and CCR1 can each be configured to generate an interrupt when a certain value in the TAR counter is reached. When the specific CCRx interrupt occurs, the TACCRx value can be adjusted to the next interval (TAR counter position) desired to generate an interrupt again. This can be done independently with each CCRx comparator in the Timer_A.

    For example, if you wanted Timer_A to generate one interrupt every 100 TAR counter clocks using CCR0 and a different interrupt every 654 TAR counter clocks using CCR1, you would configure the Timer_A for continuous mode and CCR0 and CCR1 set for comparator mode and to generate interrupts.

    When the CCR0 interrupt occurs, in it's interrupt routine, you would adjust the TACCR0 value by 100, as in:
       TACCR0 += 100;    // set CCR0 to interrupt 100 clocks from now

    When the CCR1 interrupt occurs, in it's interrupt routine, you would adjust the TACCR1 value by 654, as in:
       TACCR1 += 654;    // set CCR1 to interrupt 654 clocks from now

    With that, you have the CPU "generating independent time intervals". You can also configure the Timer_A CCRx blocks to generate the output on a pin as well to provide the "output frequencies".

    From the MSP430 LaunchPad Wiki page, you can download the MSP430G2xx1 Code Examples zip file slac463a.zip that contains several Timer0 examples you can look at to see what was done. (you may have to make minor changes to those examples depending on the compiler/development tools you're using)

    The simple example that demonstrates this is:
      msp430g2xx1_ta_01.c               Timer_A, Toggle P1.0, CCR0 Cont. Mode ISR, DCO SMCLK

    Dan

     

  • thanks Dan .... it is really helpful....

  • Dan K said:
    TACCR0 += 100;    // set CCR0 to interrupt 100 clocks from now

    That's not quite correct.

    It increases the trigger value by 100, which is 100 timer ticks from the last interrupt event. However, sicne triggering the event, the timer may have advanced before teh ISR was called and the code arrives at this point. As long as it hasn't advanced by 100 ticks, a new interrupt will be triggered exactly 100 ticks after the last interrupt trigger (but not necessarily 100 timer ticks after the ISR was executed last).

    However, if the timer has advanced by more than 100 ticks, the new value of CCRx is smaller than the current TAR value and no interrupt will occur until the timer has done a full 65536 ticks round.

    For safety, in my timer funciton, I add the distance value in a loop:

    do{
    TACCR0+=DISTANCE;
    [...]
    } while ((TACCR0-TAR)>DISTANCE);

    this ensures that when leaving the ISR, CCR0 is no more than DISTANCE ticks 'in front' (including integer overrun!) of TAR

  • thanks i was looking for the same explanation too
  • For a further explanation of Timer_A (and Timer_B), check out the MSP430 Design Workshop:
    processors.wiki.ti.com/.../MSP430_Design_Workshop

    Scott

**Attention** This is a public forum