SDAA286 March 2026 MSPM0G3519
TIMA0 with its 4 external and 2 internal CC channels can be independently used to generate 3 phase shifted PWMs. This can be achieved by utilizing the internal CC channels' SECONDARY CC event. GPTIMER provides the feature of choosing the secondary CC channel by configuring the CCCTL.CC2SELD or CCCTL.CC2SELU, depending on the counting mode(down, up, up-down).
Figure 3-2 Diagrammatic Representation of Asymmetric PWM generation using TIMA0 with Secondary Channel ApproachBased on the secondary channel selected, output generation can be done by configuring the CCACT.CC2UACT or CCACT.CC2DACT depending on the counting mode(down, up, up-down).
For example, if counter Load value is 10000 and counter is in down counting mode and CC4 value is 9000.
CCCTL[1].CC2SELD is configured as 0x4 meaning CC4 is chosen as the secondary CC channel for the main channel CC1.
CCACT[1].CC2DACT is configured as 0x1 meaning CC output value would be set as HIGH whenever counter reaches 9000 in value, which is the current CC4 value. CC4 will act as the pseudo load value for CC1.
It would be observed that the output of CC1 would go HIGH every time the counter reaches 9000 because of the CCACT[1].CC2DACT. PWM output will go LOW when the counter reaches 4000 (CC1 value).
Implementing this approach to generate three phase shifted PWMs can be useful. Using cross-trigger function to generate more sync shifted PWM output channels with multiple Timer instances.
Following the configuration sequence below to set the secondary CC channel:
/* TIMA0 Configuration for Generating Phase Shifted PWMs Using Secondary CC events */
static const DL_TimerA_ClockConfig gPWM_0ClockConfig = {
.clockSel = DL_TIMER_CLOCK_BUSCLK,
.divideRatio = DL_TIMER_CLOCK_DIVIDE_1,
.prescale = 255U
};
static const DL_TimerA_PWMConfig gPWM_0Config = {
.pwmMode = DL_TIMER_PWM_MODE_EDGE_ALIGN,
.period = 10000,
.isTimerWithFourCC = true,
.startTimer = DL_TIMER_STOP,
};
SYSCONFIG_WEAK void SYSCFG_DL_PWM_0_init(void) {
DL_TimerA_setClockConfig(
PWM_0_INST, (DL_TimerA_ClockConfig *) &gPWM_0ClockConfig);
DL_TimerA_initPWMMode(
PWM_0_INST, (DL_TimerA_PWMConfig *) &gPWM_0Config);
// Set Counter control to the smallest CC index being used
DL_TimerA_setCounterControl(PWM_0_INST,DL_TIMER_CZC_CCCTL0_ZCOND,DL_TIMER_CAC_CCCTL0_ACOND,DL_TIMER_CLC_CCCTL0_LCOND);
DL_TimerA_setCaptureCompareOutCtl(PWM_0_INST, DL_TIMER_CC_OCTL_INIT_VAL_LOW,
DL_TIMER_CC_OCTL_INV_OUT_DISABLED, DL_TIMER_CC_OCTL_SRC_FUNCVAL,
DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_0_INDEX);
DL_TimerA_setCaptureCompareOutCtl(PWM_0_INST, DL_TIMER_CC_OCTL_INIT_VAL_LOW,
DL_TIMER_CC_OCTL_INV_OUT_DISABLED, DL_TIMER_CC_OCTL_SRC_FUNCVAL,
DL_TIMERA_CAPTURE_COMPARE_1_INDEX);
DL_TimerA_setCaptCompUpdateMethod(PWM_0_INST, DL_TIMER_CC_UPDATE_METHOD_IMMEDIATE, DL_TIMERA_CAPTURE_COMPARE_1_INDEX);
PWM_0_INST->COUNTERREGS.CCCTL_01[0]=0x60000000;//Configuring CC3 as the secondary event for CC0
PWM_0_INST->COUNTERREGS.CCCTL_01[1]=0x80000000;//Configuring CC4 as the secondary event for CC1
PWM_0_INST->COUNTERREGS.CCCTL_23[0]=0xA0000000;//Configuring CC5 as the secondary event for CC2
PWM_0_INST->COUNTERREGS.CCACT_01[0]=0x00001080;//Configuring CC2DACT to drive PWM High and CDACT to drive PWM Low
PWM_0_INST->COUNTERREGS.CCACT_01[1]=0x00001080;//Configuring CC2DACT to drive PWM High and CDACT to drive PWM Low
PWM_0_INST->COUNTERREGS.CCACT_23[0]=0x00001080;//Configuring CC2DACT to drive PWM High and CDACT to drive PWM Low
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 5000, DL_TIMER_CC_0_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 4000, DL_TIMER_CC_1_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 3000, DL_TIMER_CC_2_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 9500, DL_TIMER_CC_3_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 9000, DL_TIMER_CC_4_INDEX);
DL_TimerA_setCaptureCompareValue(PWM_0_INST, 8000, DL_TIMER_CC_5_INDEX);
DL_TimerA_enableClock(PWM_0_INST);
DL_TimerA_setCCPDirection(PWM_0_INST , DL_TIMER_CC0_OUTPUT | DL_TIMER_CC1_OUTPUT |DL_TIMER_CC2_OUTPUT);
}Figure 3-3 shows the shifted PWM output waveforms. To dynamically change the period/duty cycle, refer to Section 8.
Figure 3-3 Phase Shifted PWM Generation Using TIMA0 Secondary Events