TI中文支持网
TI专业的中文技术问题搜集分享网站

6路PWM同步输出——波形0相位差

EPwm1Regs.TBPRD = 2500; //period register EPwm1Regs.TBPHS.half.TBPHS=0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = 2; // Up-Down mode // Symmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // Sync down-stream module
EPwm1Regs.TBCTL.bit.HSPCLKDIV =1;//1; //TBCLK=50M
EPwm1Regs.TBCTL.bit.CLKDIV = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; //1// load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0; //1// load on CTR=Zero
EPwm1Regs.AQCTLA.bit.CAU = 2; // set actions for EPWM1A
EPwm1Regs.AQCTLA.bit.CAD = 1; // active high EPwm1Regs.AQCTLB.bit.CAU = 1; // set actions for EPWM1B
EPwm1Regs.AQCTLB.bit.CAD = 2; //active low

EPwm1Regs.DBFED =200; // 4us
EPwm1Regs.DBRED =200; // 4us
//EPwm1Regs.DBCTL.bit.POLSEL = 1; // Active Lo complementary
EPwm1Regs.DBCTL.bit.POLSEL = 2; // Active Hi complementary
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; // enable Dead-band module

像这样依次配置6路PWM,用示波器检测的时候发现,每一路的波形之间有一个相位差,也就意味着这6个定时器不是同步启动的,请问有什么方法可以让6个定时器同步启动吗?以获得6路同步的波形。

cheng Chang1:

6路是指PWM1A PWM2A…PWM6A,而且给的占空比都是相同的。

EPwm1Regs.TBPRD = 2500; //period register EPwm1Regs.TBPHS.half.TBPHS=0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = 2; // Up-Down mode // Symmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // Sync down-stream module
EPwm1Regs.TBCTL.bit.HSPCLKDIV =1;//1; //TBCLK=50M
EPwm1Regs.TBCTL.bit.CLKDIV = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; //1// load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0; //1// load on CTR=Zero
EPwm1Regs.AQCTLA.bit.CAU = 2; // set actions for EPWM1A
EPwm1Regs.AQCTLA.bit.CAD = 1; // active high EPwm1Regs.AQCTLB.bit.CAU = 1; // set actions for EPWM1B
EPwm1Regs.AQCTLB.bit.CAD = 2; //active low

EPwm1Regs.DBFED =200; // 4us
EPwm1Regs.DBRED =200; // 4us
//EPwm1Regs.DBCTL.bit.POLSEL = 1; // Active Lo complementary
EPwm1Regs.DBCTL.bit.POLSEL = 2; // Active Hi complementary
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; // enable Dead-band module

像这样依次配置6路PWM,用示波器检测的时候发现,每一路的波形之间有一个相位差,也就意味着这6个定时器不是同步启动的,请问有什么方法可以让6个定时器同步启动吗?以获得6路同步的波形。

rookiecalf:

回复 cheng Chang1:

有和例程类似地做如下的时基同步吗:

EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; EDIS;

InitEPwm1Example(); InitEPwm2Example(); InitEPwm3Example();

EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; EDIS;

EPwm1Regs.TBPRD = 2500; //period register EPwm1Regs.TBPHS.half.TBPHS=0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = 2; // Up-Down mode // Symmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // Sync down-stream module
EPwm1Regs.TBCTL.bit.HSPCLKDIV =1;//1; //TBCLK=50M
EPwm1Regs.TBCTL.bit.CLKDIV = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; //1// load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0; //1// load on CTR=Zero
EPwm1Regs.AQCTLA.bit.CAU = 2; // set actions for EPWM1A
EPwm1Regs.AQCTLA.bit.CAD = 1; // active high EPwm1Regs.AQCTLB.bit.CAU = 1; // set actions for EPWM1B
EPwm1Regs.AQCTLB.bit.CAD = 2; //active low

EPwm1Regs.DBFED =200; // 4us
EPwm1Regs.DBRED =200; // 4us
//EPwm1Regs.DBCTL.bit.POLSEL = 1; // Active Lo complementary
EPwm1Regs.DBCTL.bit.POLSEL = 2; // Active Hi complementary
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; // enable Dead-band module

像这样依次配置6路PWM,用示波器检测的时候发现,每一路的波形之间有一个相位差,也就意味着这6个定时器不是同步启动的,请问有什么方法可以让6个定时器同步启动吗?以获得6路同步的波形。

囧:

首先,由于PWM之间内部线路传输延迟的问题,不可能通过相位同步始终没有任何误差。安装EPWM的userguide的说明,如果TBCLK是 SYSCLKOUT,那会有2个SYSCLK的误差

第二你的代码是master的代码,假如PWM2是slave,那需要修改以下两句代码:

EPwm1Regs.TBCTL.bit.PHSEN = 0, EPwm1Regs.TBCTL.bit.SYNCOSEL = 0;

这样就能保证误差是2个SYSCLK的同步

第三,你可以通过相位寄存器来补回两个SYSCLK的延时,比如PWM2,那只需要修改以下寄存器就可以:

EPwm1Regs.TBPHS.half.TBPHS=2;,可能你在调试的时候回发现并不完全是2个周期,每个PWM都可以根据实际情况调整,因为这也会被外部电路影响

EPwm1Regs.TBPRD = 2500; //period register EPwm1Regs.TBPHS.half.TBPHS=0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = 2; // Up-Down mode // Symmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // Sync down-stream module
EPwm1Regs.TBCTL.bit.HSPCLKDIV =1;//1; //TBCLK=50M
EPwm1Regs.TBCTL.bit.CLKDIV = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; //1// load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0; //1// load on CTR=Zero
EPwm1Regs.AQCTLA.bit.CAU = 2; // set actions for EPWM1A
EPwm1Regs.AQCTLA.bit.CAD = 1; // active high EPwm1Regs.AQCTLB.bit.CAU = 1; // set actions for EPWM1B
EPwm1Regs.AQCTLB.bit.CAD = 2; //active low

EPwm1Regs.DBFED =200; // 4us
EPwm1Regs.DBRED =200; // 4us
//EPwm1Regs.DBCTL.bit.POLSEL = 1; // Active Lo complementary
EPwm1Regs.DBCTL.bit.POLSEL = 2; // Active Hi complementary
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; // enable Dead-band module

像这样依次配置6路PWM,用示波器检测的时候发现,每一路的波形之间有一个相位差,也就意味着这6个定时器不是同步启动的,请问有什么方法可以让6个定时器同步启动吗?以获得6路同步的波形。

Eric Ma:

用这个就行了:

EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;EDIS;

InitEPwm1Example(); InitEPwm2Example();InitEPwm3Example();

EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;EDIS;

Eric

赞(0)
未经允许不得转载:TI中文支持网 » 6路PWM同步输出——波形0相位差
分享到: 更多 (0)