要在epwm1a和epwm1B产生频率不同的波形应该怎么编程?下面的程序产生的占空比时相同的,应该怎么修改下列程序?
void InitEPwm1()
{
//Modulatedwave();
EPwm1Regs.TBPRD = 30000; // 设置开关周期
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // 相位置零
EPwm1Regs.TBCTR = 0x0000; // 计数器清零
//时间基准控制寄存器
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // 向上波形比较
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // 禁止相位装载
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // 高速时间基准分频
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // 时间基准分频
//计数比较控制寄存器设置
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
// Set ac
tions
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
EPwm1Regs.AQCTLA.bit.CBU = AQ_CLEAR; // Set PWM1A on Zero
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM1B on Zero
EPwm1Regs.AQCTLB.bit.CBU = AQ_SET;}
void SPWM_cal(void)
{
A1_dc=Chopperwave*sin(100*PI*t+0);
if(A1_dc<0) A1_dc=0;
EPwm1Regs.CMPA.half.CMPA = 1000;
if(1000+A1_dc*30000<=30000)
EPwm1Regs.CMPB = 1000+A1_dc*30000;
else
EPwm1Regs.CMPB = A1_dc*30000-29000;}