SLAA513B December 2011 – February 2022 MSP430G2112 , MSP430G2112 , MSP430G2152 , MSP430G2152 , MSP430G2212 , MSP430G2212 , MSP430G2252 , MSP430G2252 , MSP430G2312 , MSP430G2312 , MSP430G2352 , MSP430G2352 , MSP430G2412 , MSP430G2412 , MSP430G2452 , MSP430G2452
To generate a PWM on the timer module, a second count is used to set the duty cycle. The duty cycle generated is the ratio of the number of timer counts for the high time (nhigh) to the number of timer counts for one period (nperiod). For the multiple time base method, the timer counts for the low (nlow) and high (nhigh) time are the offsets that are added into the TxCCRx register in the ISR (see Equation 3).
Figure 3-1 shows how the TxCCRx values and nhigh and nlow are used when implementing two independent PWM frequencies and duty cycles on a single MSP430 timer module. Compare this to Figure 2-1, where constant values were added to TxCCR0 and TxCCR1 to produce a 50% duty cycle.