跟着例程把A通道输出成功了,但是B通道怎么改都没反应,主要增加了标红的那一段代码
void PWM1ABasic(unsigned int pwm_clk,unsigned short duty_ratio)
{
EHRPWMTimebaseClkConfig(SOC_EHRPWM_1_REGS, SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL , SOC_EHRPWM_1_MODULE_FREQ);
// 1MHz
EHRPWMPWMOpFreqSet(SOC_EHRPWM_1_REGS,SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL,pwm_clk,EHRPWM_COUNT_UP_DOWN,EHRPWM_SHADOW_WRITE_DISABLE);
EHRPWMTimebaseSyncDisable(SOC_EHRPWM_1_REGS);
EHRPWMSyncOutModeSet(SOC_EHRPWM_1_REGS,EHRPWM_SYNCOUT_DISABLE);
EHRPWMTBEmulationModeSet(SOC_EHRPWM_1_REGS, EHRPWM_STOP_AFTER_NEXT_TB_INCREMENT);
EHRPWMLoadCMPA(SOC_EHRPWM_1_REGS,
(SOC_EHRPWM_1_MODULE_FREQ/CLOCK_DIV_VAL/pwm_clk)*duty_ratio*0.01,
EHRPWM_SHADOW_WRITE_DISABLE,
EHRPWM_COMPA_NO_LOAD, EHRPWM_CMPCTL_OVERWR_SH_FL);
EHRPWMLoadCMPB(SOC_EHRPWM_1_REGS, 10, EHRPWM_SHADOW_WRITE_DISABLE,
EHRPWM_COMPB_NO_LOAD, EHRPWM_CMPCTL_OVERWR_SH_FL);//????????????????????
EHRPWMConfigureAQActionOnA(SOC_EHRPWM_1_REGS, EHRPWM_AQCTLA_ZRO_DONOTHING,
EHRPWM_AQCTLA_PRD_DONOTHING,
EHRPWM_AQCTLA_CAU_EPWMXALOW, EHRPWM_AQCTLA_CAD_EPWMXAHIGH,
EHRPWM_AQCTLA_CBU_DONOTHING,
EHRPWM_AQCTLA_CBD_DONOTHING, EHRPWM_AQSFRC_ACTSFA_DONOTHING);//每次计数到CMPA就反转
EHRPWMConfigureAQActionOnB(SOC_EHRPWM_1_REGS, EHRPWM_AQCTLB_ZRO_DONOTHING,
EHRPWM_AQCTLB_PRD_DONOTHING,
EHRPWM_AQCTLB_CAU_EPWMXBLOW, EHRPWM_AQCTLB_CAD_EPWMXBHIGH,
EHRPWM_AQCTLB_CBU_DONOTHING,
EHRPWM_AQCTLB_CBD_DONOTHING, EHRPWM_AQSFRC_ACTSFB_DONOTHING);//每次计数到CMPA就反转
EHRPWMDBOutput(SOC_EHRPWM_1_REGS, EHRPWM_DBCTL_OUT_MODE_BYPASS);
EHRPWMChopperDisable(SOC_EHRPWM_1_REGS);
EHRPWMTZTripEventDisable(SOC_EHRPWM_1_REGS, EHRPWM_TZ_ONESHOT);
EHRPWMTZTripEventDisable(SOC_EHRPWM_1_REGS, EHRPWM_TZ_CYCLEBYCYCLE);
EHRPWMETIntPrescale(SOC_EHRPWM_1_REGS, EHRPWM_ETPS_INTPRD_THIRDEVENT);//每三次进一次中断
EHRPWMETIntSourceSelect(SOC_EHRPWM_1_REGS, EHRPWM_ETSEL_INTSEL_TBCTREQUZERO);//计数到PERIOD
EHRPWMETIntEnable(SOC_EHRPWM_1_REGS);
EHRPWMHRDisable(SOC_EHRPWM_1_REGS);
}