SLAA513B December   2011  – February 2022 MSP430G2112 , MSP430G2112 , MSP430G2152 , MSP430G2152 , MSP430G2212 , MSP430G2212 , MSP430G2252 , MSP430G2252 , MSP430G2312 , MSP430G2312 , MSP430G2352 , MSP430G2352 , MSP430G2412 , MSP430G2412 , MSP430G2452 , MSP430G2452

 

  1.   Trademarks
  2. 1Typical Single Time Base Method
  3. 2Multiple Time Base Method
  4. 3Implementing the Multiple Time Base Method in a Custom Application
    1. 3.1 Timer Clock Source Selection
    2. 3.2 Period and Frequency Calculation
    3. 3.3 Duty Cycle Calculation
  5. 4Example Code
    1. 4.1 Method
      1. 4.1.1 ISR for Multiple Frequencies
      2. 4.1.2 ISR for Multiple Frequencies and Duty Cycles (PWM)
    2. 4.2 Included Code Examples
  6. 5Limitations of the Multiple Time Base Method
    1. 5.1 ISR Overhead
    2. 5.2 Maximum Output Frequency vs Number of Signals
    3. 5.3 Power Consumption
  7. 6References
  8. 7Revision History

Multiple Time Base Method

It is possible to implement multiple timer periods on the same timer module by using Continuous Mode. In Continuous Mode, the timer always count up to 0xFFFF and then rolls over, rather than resetting at TxCCR0 each time. This means that the period is no longer set by placing a constant value in TxCCR0; rather, it is the difference between the previous and next value of TxCCRx that sets the period for each capture compare register. For example, this means that in the code, instead of setting TACCR0 = 0xFF at the beginning of the program, we would need to dynamically change TxCCR0 by 0xFF every time the counter reaches TxCCR0 (“TACCR0 += 0xFF”). Because each TxCCRx register is now completely independent from TxCCR0, a different frequency can be generated for each TxCCRx register on each timer module, drastically increasing the number of frequencies that can be produced. Figure 2-1 shows the relationship of the TxCCR0 value and two independent periods t0 and t1 in Continuous Mode. t0 corresponds to a count that is added to TxCCR0 at each interrupt, and t1 corresponds to a count that is added to TxCCR1 at each interrupt, creating the two different periods.

GUID-5747CE6D-1D41-4341-8C74-B723F84D834F-low.gifFigure 2-1 Continuous Mode Time Intervals

When using the multiple time base method, the number of frequencies and duty cycles that can be simultaneously produced on a particular MSP430 device is dependent on the total number of all TxCCRx registers on the device.

Continuing with the previous example using the MSP430F5529 device, the available timers are TA0 with five capture/compare (CC) registers, TA1 with three CC registers, TA2 with three CC registers, and TB0 with seven CC registers. Therefore, using the multiple time base method on an MSP430F5529:

Number of Frequencies and Duty Cycles = 5 CC + 3 CC + 3 CC + 7 CC = 18 frequencies and duty cycles

With the single time base method four frequencies with 14 varying duty cycles was the only option available. With the multiple time base method, any combination of the available 18 frequencies and duty cycles is available.