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

Typical Single Time Base Method

In some applications, it is necessary to generate multiple signals with unique frequencies simultaneously. In typical use of an MSP430 MCU, Up Mode or Up/Down Mode is used on the timer modules with each frequency generated corresponding to a unique timer module. Capture Compare Register 0 (TxCCR0) for each timer module is set at the beginning of the program to set the period of the timer. Additional Capture Compare Registers (TxCCRx) for each module can be set to a value at the beginning of the program to generate different duty cycles, but because the timer only counts up to the value in TxCCR0, everything on the timer module is done in reference to this same timer period. In this method, everything is set at the beginning of timer operation, and the settings are left constant from then on – everything is done in hardware, and there are no values that need to be reloaded in the ISR. Figure 1-1 shows the relationship of TxCCR0 value and period value t0 in Up Mode.

GUID-A7151A9B-BBB8-43D4-82CD-85458808B3A0-low.gifFigure 1-1 Up Mode Time Intervals

When using the single time base method, the number of frequencies that can be simultaneously produced on a particular MSP430 device is dependent on the number of timer modules on the MSP430 device, and the number of possible simultaneous duty cycles is dependent on the number of TxCCRx registers on each module minus 1.

For example, an MSP430F5529 device features 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 single time base method on an MSP430F5529:

Number of Frequencies = 3 Timer_A modules + 1 Timer_B module = 4 Independent Frequencies

Number of Duty Cycles TA0 = 5 CC – 1 = 4 Duty Cycles at TA0 frequency

Number of Duty Cycles TA1 = 3 CC – 1 = 2 Duty Cycles at TA1 frequency

Number of Duty Cycles TA2 = 3 CC – 1 = 2 Duty Cycles at TA2 frequency

Number of Duty Cycles TB0 = 7 CC – 1 = 6 Duty Cycles at TB0 frequency