Hi,
My power converter works as bidirectional. Therefore, I need to change my PWM configuration at some working states.
1) Which method do you offer to change PWM configuration after init? Do I need to write new configuration to registers at ISR or a task that is called at 1msec? Which is safe and flexible to achieve?
2) Do I need to write EALLOW, EDIS lines during configuration change at changing ISR or timer tast?
3) Which PWM configurations can be changed after init which cannot?
4) In my case, I observed a problem during configuration change. I only change AQ module setting.
If I " EPWM_enablePhaseShiftLoad(EPWM3_BASE);" write during initing , after changing configuration. My PWM doesn't work as expected.
MY INIT CODE
EALLOW; // // Time-Base Submodule Configurations // EPWM_setPeriodLoadMode(EPWM3_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_setTimeBasePeriod(EPWM3_BASE, ITIB_PERIOD_TICKS); EPWM_setTimeBaseCounter(EPWM3_BASE, 0); EPWM_setPhaseShift(EPWM3_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setClockPrescaler(EPWM3_BASE,EPWM_CLOCK_DIVIDER_1,EPWM_HSCLOCK_DIVIDER_1); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, 100); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_B, 0); // Counter-Compare Submodule Configurations // CMPA is updated on ZERO // CMPB is updated on PERIODE !!! EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_B, EPWM_COMP_LOAD_ON_CNTR_PERIOD); EPWM_setActionQualifierShadowLoadMode(EPWM3_BASE, EPWM_ACTION_QUALIFIER_A, EPWM_AQ_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierShadowLoadMode(EPWM3_BASE, EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_CNTR_PERIOD); // // to start don't configure the PWM to do anything // HWREGH(EPWM3_BASE + EPWM_O_AQCTLA) = 0; // Action-Qualifier Submodule Configurations // ePWM3A Actions // CTR = ZERO , set to no action // CTR = PRD , set to no action // CTR = CMPA , set to 1 (Counting Up) // CTR = CMPA , set to 0 (Counting Down) // CTR = T1U , set to no action // CTR = T1D , set to no action EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_T1_COUNT_UP); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN); // Action-Qualifier Submodule Configurations // ePWM3B Actions // CTR = ZERO , set to no action // CTR = PRD , set to no action // CTR = CMPB, set to 0 (Counting Up) // CTR = CMPB, set to 1 (Counting Down) // CTR = T1U , set to no action // CTR = T1D , set to no action EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_T1_COUNT_UP); EPWM_setActionQualifierAction(EPWM3_BASE,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN); //EPWM_enablePhaseShiftLoad(EPWM3_BASE); EPWM_setSyncOutPulseMode(EPWM3_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN); EPWM_setPhaseShift(EPWM3_BASE, 2); // Value*TBCLKs Phase-Shift is Set EPWM_setCountModeAfterSync(EPWM3_BASE, EPWM_COUNT_MODE_UP_AFTER_SYNC);
MY CHANGE PWM CONFIGURATION CODE (THAT RUNS ONE TIME AT ISR)
EALLOW; // Action-Qualifier Submodule Configurations // ePWM3A Actions // CTR = ZERO , set to no action // CTR = PRD , set to no action // CTR = CMPA , set to 1 (Counting Up) // CTR = CMPA , set to 0 (Counting Down) // CTR = T1U , set to no action // CTR = T1D , set to no action EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_T1_COUNT_UP); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN); // Action-Qualifier Submodule Configurations // ePWM3B Actions // CTR = ZERO , set to no action // CTR = PRD , set to no action // CTR = CMPB, set to 0 (Counting Up) // CTR = CMPB, set to 1 (Counting Down) // CTR = T1U , set to no action // CTR = T1D , set to no action EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_T1_COUNT_UP); EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN); EDIS;