代码如下,求解TMS320F28027 PWM 设计在用UP-DOWN 模式下出不来PWM 急
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; //设置为PWM模式
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // disable pullup on GPIO0
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; //设置为PWM模式
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // disable pullup on GPIO0
//设置时钟 系统时钟/HSPCLKDIV*CLKDIV
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0x00;
EPwm1Regs.TBCTL.bit.CLKDIV = 0x00;
//如上设置时间为1/50M = 20ns
EPwm1Regs.TBPRD= 1000; // 设置周期为20u 1MHZ的频率
//不用同步
EPwm1Regs.TBCTL.bit.SYNCOSEL=0x00;
EPwm1Regs.TBCTL.bit.PHSEN = 0X00; // 同步信号使能信号
EPwm1Regs.TBPHS.half.TBPHS = 0X00; //同步信号使能后偏移信号
EPwm1Regs.TBCTR =0X00;
EPwm1Regs.TBCTL.bit.CTRMODE = 0X02; //计数模式
EPwm1Regs.TBCTL.bit.PRDLD = 0X00; //设置TBPRD的加载模式 为上下
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x00;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0x00;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0X00;
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0X00;
EPwm1Regs.AQCTLA.bit.ZRO = 0X02;//设置计数器到达额定值的时候的动作
EPwm1Regs.AQCTLA.bit.CAU = 0X01;//设置计数器到达CMPA值时的动作
EPwm1Regs.CMPA.half.CMPA = 500;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // disable pullup on GPIO0
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; //设置为PWM模式
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // disable pullup on GPIO0
//设置时钟 系统时钟/HSPCLKDIV*CLKDIV
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0x00;
EPwm1Regs.TBCTL.bit.CLKDIV = 0x00;
//如上设置时间为1/50M = 20ns
EPwm1Regs.TBPRD= 1000; // 设置周期为20u 1MHZ的频率
//不用同步
EPwm1Regs.TBCTL.bit.SYNCOSEL=0x00;
EPwm1Regs.TBCTL.bit.PHSEN = 0X00; // 同步信号使能信号
EPwm1Regs.TBPHS.half.TBPHS = 0X00; //同步信号使能后偏移信号
EPwm1Regs.TBCTR =0X00;
EPwm1Regs.TBCTL.bit.CTRMODE = 0X02; //计数模式
EPwm1Regs.TBCTL.bit.PRDLD = 0X00; //设置TBPRD的加载模式 为上下
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x00;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0x00;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0X00;
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0X00;
EPwm1Regs.AQCTLA.bit.ZRO = 0X02;//设置计数器到达额定值的时候的动作
EPwm1Regs.AQCTLA.bit.CAU = 0X01;//设置计数器到达CMPA值时的动作
EPwm1Regs.CMPA.half.CMPA = 500;
Shine:
TMS320F28027 属于C2000系列,请到专门的C2000论坛咨询。
e2echina.ti.com/…/