4路PWM发波,以PWM1为基准其余三路都是以PWM1为同步信号 采用向上向下计数模式,后三路移项值一直给的是(PRD-2)目的是在变频时保持同一相位,现在的问题是PWM的频率发生变化时波形会出现杂乱,好像是重新做了同步发波的处理,请问这是什么原因,怎么解决
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
4路PWM发波,以PWM1为基准其余三路都是以PWM1为同步信号 采用向上向下计数模式,后三路移项值一直给的是(PRD-2)目的是在变频时保持同一相位,现在的问题是PWM的频率发生变化时波形会出现杂乱,好像是重新做了同步发波的处理,请问这是什么原因,怎么解决
您好
感谢您对TI产品的关注!为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上(https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum),将由资深的英文论坛工程师为您提供帮助。
您好
感谢您对TI产品的关注!为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上(https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum),将由资深的英文论坛工程师为您提供帮助。相关资深的工程师可以给您提供相关代码参考。
void mcu_epwm1_init() { EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM1_BASE, 1000); EPWM_setTimeBaseCounter(EPWM1_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM1_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM1_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_disablePhaseShiftLoad(EPWM1_BASE); // EPWM_enablePhaseShiftLoad(EPWM1_BASE); // EPWM_setPhaseShift(EPWM1_BASE, 0); ///Synchronize EPWM_setSyncInPulseSource(EPWM1_BASE, EPWM_SYNC_IN_PULSE_SRC_DISABLE); EPWM_enableSyncOutPulseSource(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_ALL); /* EPWM1 A */ /// GPIO //GPIO_setPinConfig(EPWM1_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM1_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM1_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); // EPWM_setActionQualifierShadowLoadMode(EPWM1_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /* EPWM1 B */ /// Dead band EPWM_setDeadBandDelayPolarity(EPWM1_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM1_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM1_BASE, 0); //EPWM_setRisingEdgeDelayCountShadowLoadMode(EPWM1_BASE, EPWM_RED_LOAD_ON_CNTR_ZERO); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM1_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM1_BASE, 0); } void mcu_epwm2_init() { EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM2_BASE, 1000); EPWM_setTimeBaseCounter(EPWM2_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM2_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM2_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM2_BASE); EPWM_setPhaseShift(EPWM2_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM2_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM2_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM2_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM2 A */ /// GPIO //GPIO_setPinConfig(EPWM2_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM2_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM2_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM2_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM2_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM2_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM2_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM2_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM2_BASE, 0); } void mcu_epwm3_init() { EPWM_setClockPrescaler(EPWM3_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM3_BASE, 1000); EPWM_setTimeBaseCounter(EPWM3_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM3_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM3_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM3_BASE); EPWM_setPhaseShift(EPWM3_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM3_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM3_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM3_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM1 A */ /// GPIO GPIO_setPadConfig(EPWM3_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM3_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); 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_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM3_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM3_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM3_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM3_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM3_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM3_BASE, 0); } void mcu_epwm4_init() { EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM4_BASE, 1000); EPWM_setTimeBaseCounter(EPWM4_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM4_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM4_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM4_BASE); EPWM_setPhaseShift(EPWM4_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM4_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM4_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM4 A */ /// GPIO //GPIO_setPinConfig(EPWM4_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM4_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM4_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM4_BASE, EPWM_COUNTER_COMPARE_A,500); EPWM_setCounterCompareShadowLoadMode(EPWM4_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM4_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM4_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM4_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM4_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM4_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM4_BASE, 0); }
你好,感谢回复,目前我试了一下,如果不做同步处理或者不移相的话,变频不会出现问题,或者移相的值不变的话也不会出现,应该是变频后强制同步波形导致的,但是具体解决办法还没找到。麻烦帮忙看一下代码,谢谢
void mcu_epwm1_init() { EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM1_BASE, 1000); EPWM_setTimeBaseCounter(EPWM1_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM1_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM1_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_disablePhaseShiftLoad(EPWM1_BASE); // EPWM_enablePhaseShiftLoad(EPWM1_BASE); // EPWM_setPhaseShift(EPWM1_BASE, 0); ///Synchronize EPWM_setSyncInPulseSource(EPWM1_BASE, EPWM_SYNC_IN_PULSE_SRC_DISABLE); EPWM_enableSyncOutPulseSource(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_ALL); /* EPWM1 A */ /// GPIO //GPIO_setPinConfig(EPWM1_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM1_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM1_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); // EPWM_setActionQualifierShadowLoadMode(EPWM1_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /* EPWM1 B */ /// Dead band EPWM_setDeadBandDelayPolarity(EPWM1_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM1_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM1_BASE, 0); //EPWM_setRisingEdgeDelayCountShadowLoadMode(EPWM1_BASE, EPWM_RED_LOAD_ON_CNTR_ZERO); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM1_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM1_BASE, 0); } void mcu_epwm2_init() { EPWM_setClockPrescaler(EPWM2_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM2_BASE, 1000); EPWM_setTimeBaseCounter(EPWM2_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM2_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM2_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM2_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM2_BASE); EPWM_setPhaseShift(EPWM2_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM2_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM2_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM2_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM2 A */ /// GPIO //GPIO_setPinConfig(EPWM2_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM2_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM2_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM2_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM2_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM2_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM2_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM2_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM2_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM2_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM2_BASE, 0); } void mcu_epwm3_init() { EPWM_setClockPrescaler(EPWM3_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM3_BASE, 1000); EPWM_setTimeBaseCounter(EPWM3_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM3_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM3_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM3_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM3_BASE); EPWM_setPhaseShift(EPWM3_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM3_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM3_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM3_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM1 A */ /// GPIO GPIO_setPadConfig(EPWM3_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM3_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, 500); EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); 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_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM3_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM3_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM3_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM3_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM3_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM3_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM3_BASE, 0); } void mcu_epwm4_init() { EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1, EPWM_HSCLOCK_DIVIDER_1); EPWM_setTimeBasePeriod(EPWM4_BASE, 1000); EPWM_setTimeBaseCounter(EPWM4_BASE, 0); EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP_DOWN); EPWM_setPeriodLoadMode(EPWM4_BASE, EPWM_PERIOD_SHADOW_LOAD); EPWM_selectPeriodLoadEvent(EPWM4_BASE, EPWM_SHADOW_LOAD_MODE_COUNTER_SYNC); ///Phase EPWM_enablePhaseShiftLoad(EPWM4_BASE); EPWM_setPhaseShift(EPWM4_BASE, 0); // EPWM_disablePhaseShiftLoad(EPWM4_BASE); ///Synchronize EPWM_setSyncInPulseSource(EPWM4_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM1); EPWM_disableSyncOutPulseSource(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); /* EPWM4 A */ /// GPIO //GPIO_setPinConfig(EPWM4_EPWMA_PIN_CONFIG); GPIO_setPadConfig(EPWM4_EPWMA_GPIO, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(EPWM4_EPWMA_GPIO, GPIO_QUAL_SYNC); EPWM_setCounterCompareValue(EPWM4_BASE, EPWM_COUNTER_COMPARE_A,500); EPWM_setCounterCompareShadowLoadMode(EPWM4_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_CNTR_ZERO); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB); EPWM_setActionQualifierAction(EPWM4_BASE, EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_NO_CHANGE, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB); EPWM_setActionQualifierShadowLoadMode(EPWM4_BASE,EPWM_ACTION_QUALIFIER_B, EPWM_AQ_LOAD_ON_SYNC_ONLY); /// Dead band EPWM_setDeadBandDelayPolarity(EPWM4_BASE, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW); /// Rising Edge EPWM_setDeadBandDelayMode(EPWM4_BASE, EPWM_DB_RED, true); EPWM_setRisingEdgeDelayCount(EPWM4_BASE, 0); /// Falling Edge EPWM_setDeadBandDelayMode(EPWM4_BASE, EPWM_DB_FED, true); EPWM_setFallingEdgeDelayCount(EPWM4_BASE, 0); }你好,感谢回复,目前我试了一下,如果不做同步处理或者不移相的话,变频不会出现问题,或者移相的值不变的话也不会出现,应该是变频后强制同步波形导致的,但是具体解决办法还没找到。麻烦帮忙看一下代码,谢谢
您好
感谢您对TI产品的关注!为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上(https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum),将由资深的英文论坛工程师为您提供帮助。相关资深的工程师可以给您提供相关代码参考。