Part Number: TMS320F28379D
Hi,
I am trying to utilise PWMs to require updating only one PWM and letting the configuration update the other PWMs. So the basic premise is:
- PWM1, PWM2, PWM3 are configured the same.
- PWM1 -> Sync -> PWM2
- PWM2 -> Sync -> PWM3
- Configure Global Load for PWM2 and PWM3.
I intend to change Frequency of the PWM1 (TBPRD) and Duty (CMPA) and I'd like to utilise the Global load to update these registers in the PWM2 and PWM3.
I have PWM1 changing frequency and duty, no problem. However, the Global Load does not seem to work. Here is my configuration (PWM1 -> PWM2)
Every PWM module is configured using this function.
STATIC void bsw_pwm_init_module(uint32_t base)
{
EPWM_setTimeBasePeriod(base, 0U);
EPWM_setPhaseShift(base, 0U);
EPWM_setTimeBaseCounter(base, 0U);
bsw_pwm_set_duty(base, 0U);
EPWM_setTimeBaseCounterMode(base, EPWM_COUNTER_MODE_UP);
EPWM_disablePhaseShiftLoad(base);
EPWM_setClockPrescaler(base,
EPWM_CLOCK_DIVIDER_1,
EPWM_HSCLOCK_DIVIDER_1);
EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, true);
EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, true);
EPWM_setRisingEdgeDelayCount(base, s_config.dt_ticks);
EPWM_setFallingEdgeDelayCount(base, s_config.dt_ticks);
EPWM_setDeadBandDelayPolarity(base, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_HIGH);
EPWM_setDeadBandDelayPolarity(base, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW);
EPWM_setCounterCompareShadowLoadMode(base,
EPWM_COUNTER_COMPARE_A,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
bsw_pwm_config_module_actions(base);
}
Additional configuration is carried individually for each Module.
#define GLOBAL_LOAD_REGS (EPWM_GL_REGISTER_TBPRD_TBPRDHR |\
EPWM_GL_REGISTER_CMPA_CMPAHR |\
EPWM_GL_REGISTER_CMPB_CMPBHR |\
EPWM_GL_REGISTER_DBRED_DBREDHR |\
EPWM_GL_REGISTER_DBFED_DBFEDHR |\
EPWM_GL_REGISTER_DBCTL)
STATIC void bsw_pwm_init_modules(void) { bsw_pwm_init_module(HV_PH1_MODULE); EPWM_setSyncOutPulseMode(HV_PH1_MODULE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO); bsw_pwm_init_module(HV_PH2_MODULE); EPWM_setGlobalLoadEventPrescale(HV_PH2_MODULE, 1U); EPWM_setSyncOutPulseMode(HV_PH2_MODULE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN); EPWM_enablePhaseShiftLoad(HV_PH2_MODULE); /* Phase Shift within HV and LV, these should never change */ bsw_pwm_set_phase_shift(HV_PH2_MODULE, 120.0f); EPWM_enableGlobalLoad(HV_PH2_MODULE); EPWM_setGlobalLoadTrigger(HV_PH2_MODULE, EPWM_GL_LOAD_PULSE_SYNC); EPWM_enableGlobalLoadRegisters(HV_PH2_MODULE, GLOBAL_LOAD_REGS); }