Part Number: TMS320F28379D
I have a project that makes use of all 12 PWM modules by CPU2. All are configured nearly identically, however only PWM<7-12> appear to work when probing the output, the 12 output pins corresponding to PWM<1-6> are either high or low with no switching.
Below shown is the configuration for EPWM6, but nearly the same configuration is used for all.
void init()
{
// PWM H
GPIO_setPadConfig(10, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_10_EPWM6A);
GPIO_setMasterCore(10, GPIO_CORE_CPU2);
// PWM L
GPIO_setPadConfig(11, GPIO_PIN_TYPE_STD);
GPIO_setPinConfig(GPIO_11_EPWM6B);
GPIO_setMasterCore(11, GPIO_CORE_CPU2);
SysCtl_selectCPUForPeripheral(SYSCTL_CPUSEL0_EPWM, 6, SYSCTL_CPUSEL_CPU2);
base = EPWM6_BASE;
EPWM_setTimeBasePeriod(base, 1000);
EPWM_setPhaseShift(base, 0U);
EPWM_setTimeBaseCounter(base, 0U);
EPWM_disableInterrupt(base);
EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_A, 0U);
EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_B, 0U);
EPWM_setTimeBaseCounterMode(base, EPWM_COUNTER_MODE_UP_DOWN);
EPWM_disablePhaseShiftLoad(base);
EPWM_setClockPrescaler(base, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1);
EPWM_setCounterCompareShadowLoadMode(base, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO);
EPWM_setCounterCompareShadowLoadMode(base, EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_ZERO);
EPWM_setActionQualifierAction(base, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
EPWM_setActionQualifierAction(base, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
EPWM_setActionQualifierAction(base, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
EPWM_setActionQualifierAction(base, EPWM_AQ_OUTPUT_B, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
EPWM_setInterruptSource(base, EPWM_INT_TBCTR_ZERO);
EPWM_enableInterrupt(base);
EPWM_setInterruptEventCount(base, 10);
Interrupt_enable(INT_EPWM6);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
}
__interrupt void pwm_isr(void)
{
// new_val as placeholder for this demo
EPWM_setCounterCompareValue(EPWM6_BASE, EPWM_COUNTER_COMPARE_A, new_val);
EPWM_setCounterCompareValue(EPWM6_BASE, EPWM_COUNTER_COMPARE_B, new_val);
EPWM_clearEventTriggerInterruptFlag(EPWM6_BASE);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}
Note: the SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC) call is included above for completeness. In reality, it isn't called until all PWMs are setup.
I initially thought something could be going wrong with the interrupt configuration and handling, however if I disable the interrupts for PWM<1-6> and update their compare registers from the ISRs of PWM<7-12> it still doesn't work.