我的配置如下
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pull-up on GPIO0 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pull-up on GPIO1 (EPWM1B)
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
EDIS;
//EPwmReg1:
EPwm1Regs.TBCTL.all = 0xE010; //时基控制寄存器
EPwm1Regs.ETPS.all = 0x0100; //事件触发预分频寄存器
EPwm1Regs.ETSEL.all = 0x0A00; //事件触发选择寄存器
EPwm1Regs.TBCTR = 0x0000; //时基计数器初始化为0
EPwm1Regs.TBPRD = PWM_PRIED; //PWM周期值=1500
EPwm1Regs.TBPHS.half.TBPHS = 0x00; //时基计数器相位初始为0
EPwm1Regs.CMPA.half.CMPA = 0x0000; //CMPA=0
EPwm1Regs.CMPB = HALF_PWM_PRIED; //CMPB=750
EPwm1Regs.CMPCTL.all = 0x0000; //计数比较控制寄存器
EPwm1Regs.AQCTLA.all = 0x0120; //动作控制寄存器A
EPwm1Regs.AQCTLB.all = 0x0210; //动作控制寄存器B
EPwm1Regs.AQSFRC.all = 0x00C0; //动作软件强制寄存器
EPwm1Regs.AQCSFRC.all = 0x0000; //动作连续软件强制寄存器
EPwm1Regs.DBCTL.bit.IN_MODE = 00; //PWMA是双边沿延时输入源
EPwm1Regs.DBCTL.bit.POLSEL = 2; //PWMA不翻转,PWMB翻转
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; //使能双边沿延时
EPwm1Regs.DBFED = PWM_DEADTIME; //下降沿死区=150
EPwm1Regs.DBRED = PWM_DEADTIME; //上升沿死区=150
EPwm1Regs.PCCTL.bit.CHPEN = 0; //禁止PWM斩波功能
EALLOW;
EPwm1Regs.TZCTL.all = 0x000A; //当错误事件发生时,ePWMA、ePWMB输出强制低
EDIS;
这样配置后我用下面的程序强制是输出低电平,发现PWMxA总是低的,PWMxB总为高
void PWM_Disable_Func()
{
EPwm1Regs.AQCSFRC.bit.CSFA = 1;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
EPwm2Regs.AQCSFRC.bit.CSFA = 1;
EPwm2Regs.AQCSFRC.bit.CSFB = 1;
EALLOW;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EPwm2Regs.TZCLR.bit.OST = 1;
EPwm2Regs.TZCLR.bit.INT = 1;
EDIS;
}
请大家帮帮忙,有知道的告诉我一下,谢谢
mangui zhang:
如果不强制输出高或低的话 是不是能正常输出PWM波
如果可以 就可以排除外部强制拉高或拉低的硬件问题
我的配置如下
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pull-up on GPIO0 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pull-up on GPIO1 (EPWM1B)
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
EDIS;
//EPwmReg1:
EPwm1Regs.TBCTL.all = 0xE010; //时基控制寄存器
EPwm1Regs.ETPS.all = 0x0100; //事件触发预分频寄存器
EPwm1Regs.ETSEL.all = 0x0A00; //事件触发选择寄存器
EPwm1Regs.TBCTR = 0x0000; //时基计数器初始化为0
EPwm1Regs.TBPRD = PWM_PRIED; //PWM周期值=1500
EPwm1Regs.TBPHS.half.TBPHS = 0x00; //时基计数器相位初始为0
EPwm1Regs.CMPA.half.CMPA = 0x0000; //CMPA=0
EPwm1Regs.CMPB = HALF_PWM_PRIED; //CMPB=750
EPwm1Regs.CMPCTL.all = 0x0000; //计数比较控制寄存器
EPwm1Regs.AQCTLA.all = 0x0120; //动作控制寄存器A
EPwm1Regs.AQCTLB.all = 0x0210; //动作控制寄存器B
EPwm1Regs.AQSFRC.all = 0x00C0; //动作软件强制寄存器
EPwm1Regs.AQCSFRC.all = 0x0000; //动作连续软件强制寄存器
EPwm1Regs.DBCTL.bit.IN_MODE = 00; //PWMA是双边沿延时输入源
EPwm1Regs.DBCTL.bit.POLSEL = 2; //PWMA不翻转,PWMB翻转
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; //使能双边沿延时
EPwm1Regs.DBFED = PWM_DEADTIME; //下降沿死区=150
EPwm1Regs.DBRED = PWM_DEADTIME; //上升沿死区=150
EPwm1Regs.PCCTL.bit.CHPEN = 0; //禁止PWM斩波功能
EALLOW;
EPwm1Regs.TZCTL.all = 0x000A; //当错误事件发生时,ePWMA、ePWMB输出强制低
EDIS;
这样配置后我用下面的程序强制是输出低电平,发现PWMxA总是低的,PWMxB总为高
void PWM_Disable_Func()
{
EPwm1Regs.AQCSFRC.bit.CSFA = 1;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
EPwm2Regs.AQCSFRC.bit.CSFA = 1;
EPwm2Regs.AQCSFRC.bit.CSFB = 1;
EALLOW;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EPwm2Regs.TZCLR.bit.OST = 1;
EPwm2Regs.TZCLR.bit.INT = 1;
EDIS;
}
请大家帮帮忙,有知道的告诉我一下,谢谢
Eric Ma:
如果用AQCSFRC这种方式,你需要把死区关掉。因为AQCSFRC只是强制AQ模块输出的PWM信号,但是后面它还会通过死区模块,死区模块只用到AQ输出的PWMA,PWMB是由PWMA翻转而来,所以输出到引脚上的,就仍然是一个互补的信号。
如果你要达到强制拉低拉高的方式,建议使用TZ模块的功能,配置OST模式,如果有OST信号,PWM引脚拉低,然后通过TZFRC软件产生OST,则可拉低,使用TZCLR可清楚OST。
Eric
我的配置如下
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pull-up on GPIO0 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pull-up on GPIO1 (EPWM1B)
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
EDIS;
//EPwmReg1:
EPwm1Regs.TBCTL.all = 0xE010; //时基控制寄存器
EPwm1Regs.ETPS.all = 0x0100; //事件触发预分频寄存器
EPwm1Regs.ETSEL.all = 0x0A00; //事件触发选择寄存器
EPwm1Regs.TBCTR = 0x0000; //时基计数器初始化为0
EPwm1Regs.TBPRD = PWM_PRIED; //PWM周期值=1500
EPwm1Regs.TBPHS.half.TBPHS = 0x00; //时基计数器相位初始为0
EPwm1Regs.CMPA.half.CMPA = 0x0000; //CMPA=0
EPwm1Regs.CMPB = HALF_PWM_PRIED; //CMPB=750
EPwm1Regs.CMPCTL.all = 0x0000; //计数比较控制寄存器
EPwm1Regs.AQCTLA.all = 0x0120; //动作控制寄存器A
EPwm1Regs.AQCTLB.all = 0x0210; //动作控制寄存器B
EPwm1Regs.AQSFRC.all = 0x00C0; //动作软件强制寄存器
EPwm1Regs.AQCSFRC.all = 0x0000; //动作连续软件强制寄存器
EPwm1Regs.DBCTL.bit.IN_MODE = 00; //PWMA是双边沿延时输入源
EPwm1Regs.DBCTL.bit.POLSEL = 2; //PWMA不翻转,PWMB翻转
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; //使能双边沿延时
EPwm1Regs.DBFED = PWM_DEADTIME; //下降沿死区=150
EPwm1Regs.DBRED = PWM_DEADTIME; //上升沿死区=150
EPwm1Regs.PCCTL.bit.CHPEN = 0; //禁止PWM斩波功能
EALLOW;
EPwm1Regs.TZCTL.all = 0x000A; //当错误事件发生时,ePWMA、ePWMB输出强制低
EDIS;
这样配置后我用下面的程序强制是输出低电平,发现PWMxA总是低的,PWMxB总为高
void PWM_Disable_Func()
{
EPwm1Regs.AQCSFRC.bit.CSFA = 1;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
EPwm2Regs.AQCSFRC.bit.CSFA = 1;
EPwm2Regs.AQCSFRC.bit.CSFB = 1;
EALLOW;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EPwm2Regs.TZCLR.bit.OST = 1;
EPwm2Regs.TZCLR.bit.INT = 1;
EDIS;
}
请大家帮帮忙,有知道的告诉我一下,谢谢
user1333144:
回复 Eric Ma:
清除OST的位置可不可以确定,因为我发送固定占空比,发现清除OST的时候,第一个看空比的是能的位置是随机的.能不能设置为ZRO生效或者PRD生效,28035mcu
我的配置如下
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pull-up on GPIO0 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pull-up on GPIO1 (EPWM1B)
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
EDIS;
//EPwmReg1:
EPwm1Regs.TBCTL.all = 0xE010; //时基控制寄存器
EPwm1Regs.ETPS.all = 0x0100; //事件触发预分频寄存器
EPwm1Regs.ETSEL.all = 0x0A00; //事件触发选择寄存器
EPwm1Regs.TBCTR = 0x0000; //时基计数器初始化为0
EPwm1Regs.TBPRD = PWM_PRIED; //PWM周期值=1500
EPwm1Regs.TBPHS.half.TBPHS = 0x00; //时基计数器相位初始为0
EPwm1Regs.CMPA.half.CMPA = 0x0000; //CMPA=0
EPwm1Regs.CMPB = HALF_PWM_PRIED; //CMPB=750
EPwm1Regs.CMPCTL.all = 0x0000; //计数比较控制寄存器
EPwm1Regs.AQCTLA.all = 0x0120; //动作控制寄存器A
EPwm1Regs.AQCTLB.all = 0x0210; //动作控制寄存器B
EPwm1Regs.AQSFRC.all = 0x00C0; //动作软件强制寄存器
EPwm1Regs.AQCSFRC.all = 0x0000; //动作连续软件强制寄存器
EPwm1Regs.DBCTL.bit.IN_MODE = 00; //PWMA是双边沿延时输入源
EPwm1Regs.DBCTL.bit.POLSEL = 2; //PWMA不翻转,PWMB翻转
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; //使能双边沿延时
EPwm1Regs.DBFED = PWM_DEADTIME; //下降沿死区=150
EPwm1Regs.DBRED = PWM_DEADTIME; //上升沿死区=150
EPwm1Regs.PCCTL.bit.CHPEN = 0; //禁止PWM斩波功能
EALLOW;
EPwm1Regs.TZCTL.all = 0x000A; //当错误事件发生时,ePWMA、ePWMB输出强制低
EDIS;
这样配置后我用下面的程序强制是输出低电平,发现PWMxA总是低的,PWMxB总为高
void PWM_Disable_Func()
{
EPwm1Regs.AQCSFRC.bit.CSFA = 1;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
EPwm2Regs.AQCSFRC.bit.CSFA = 1;
EPwm2Regs.AQCSFRC.bit.CSFB = 1;
EALLOW;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EPwm2Regs.TZCLR.bit.OST = 1;
EPwm2Regs.TZCLR.bit.INT = 1;
EDIS;
}
请大家帮帮忙,有知道的告诉我一下,谢谢
user1333144:
回复 Eric Ma:
清除OST的位置可不可以确定,因为我发送固定占空比,发现清除OST的时候,第一个看空比的是能的位置是随机的.能不能设置为ZRO生效或者PRD生效,28035mcu
我的配置如下
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pull-up on GPIO0 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pull-up on GPIO1 (EPWM1B)
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
EDIS;
//EPwmReg1:
EPwm1Regs.TBCTL.all = 0xE010; //时基控制寄存器
EPwm1Regs.ETPS.all = 0x0100; //事件触发预分频寄存器
EPwm1Regs.ETSEL.all = 0x0A00; //事件触发选择寄存器
EPwm1Regs.TBCTR = 0x0000; //时基计数器初始化为0
EPwm1Regs.TBPRD = PWM_PRIED; //PWM周期值=1500
EPwm1Regs.TBPHS.half.TBPHS = 0x00; //时基计数器相位初始为0
EPwm1Regs.CMPA.half.CMPA = 0x0000; //CMPA=0
EPwm1Regs.CMPB = HALF_PWM_PRIED; //CMPB=750
EPwm1Regs.CMPCTL.all = 0x0000; //计数比较控制寄存器
EPwm1Regs.AQCTLA.all = 0x0120; //动作控制寄存器A
EPwm1Regs.AQCTLB.all = 0x0210; //动作控制寄存器B
EPwm1Regs.AQSFRC.all = 0x00C0; //动作软件强制寄存器
EPwm1Regs.AQCSFRC.all = 0x0000; //动作连续软件强制寄存器
EPwm1Regs.DBCTL.bit.IN_MODE = 00; //PWMA是双边沿延时输入源
EPwm1Regs.DBCTL.bit.POLSEL = 2; //PWMA不翻转,PWMB翻转
EPwm1Regs.DBCTL.bit.OUT_MODE = 3; //使能双边沿延时
EPwm1Regs.DBFED = PWM_DEADTIME; //下降沿死区=150
EPwm1Regs.DBRED = PWM_DEADTIME; //上升沿死区=150
EPwm1Regs.PCCTL.bit.CHPEN = 0; //禁止PWM斩波功能
EALLOW;
EPwm1Regs.TZCTL.all = 0x000A; //当错误事件发生时,ePWMA、ePWMB输出强制低
EDIS;
这样配置后我用下面的程序强制是输出低电平,发现PWMxA总是低的,PWMxB总为高
void PWM_Disable_Func()
{
EPwm1Regs.AQCSFRC.bit.CSFA = 1;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
EPwm2Regs.AQCSFRC.bit.CSFA = 1;
EPwm2Regs.AQCSFRC.bit.CSFB = 1;
EALLOW;
EPwm1Regs.TZCLR.bit.OST = 1;
EPwm1Regs.TZCLR.bit.INT = 1;
EPwm2Regs.TZCLR.bit.OST = 1;
EPwm2Regs.TZCLR.bit.INT = 1;
EDIS;
}
请大家帮帮忙,有知道的告诉我一下,谢谢
user1333144:
回复 Eric Ma:
Eric Ma
如果用AQCSFRC这种方式,你需要把死区关掉。因为AQCSFRC只是强制AQ模块输出的PWM信号,但是后面它还会通过死区模块,死区模块只用到AQ输出的PWMA,PWMB是由PWMA翻转而来,所以输出到引脚上的,就仍然是一个互补的信号。
如果你要达到强制拉低拉高的方式,建议使用TZ模块的功能,配置OST模式,如果有OST信号,PWM引脚拉低,然后通过TZFRC软件产生OST,则可拉低,使用TZCLR可清楚OST。
Eric