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

不解事件?PWM强制电平不起作用!TMS28062

/****************************/
// EPWM2A/B
/****************************/
//时基模块
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // Pass through
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;//TB_ENABLE;
EPwm2Regs.TBPHS.half.TBPHS = 0;
EPwm2Regs.TBCTR = 0x0000;
EPwm2Regs.TBPRD = PWM_INV_TBPRD; // 216us
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
//中断模块
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Enable INT on Zero event
EPwm2Regs.ETSEL.bit.INTEN = 1;//PWM2_INT_ENABLE; // Enable INT
EPwm2Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 2nd event

EPwm2Regs.ETSEL.bit.SOCAEN = 1;
EPwm2Regs.ETSEL.bit.SOCASEL = 1; //ZERO
EPwm2Regs.ETPS.bit.SOCAPRD = 1; //1st
//EPwm2Regs.ETPS.bit.SOCACNT = 1; //1st

//配置比较模块
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
//EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_IMMEDIATE;
//EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_IMMEDIATE;
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD; //CC_CTR_ZERO_PRD //CC_CTR_ZERO
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;

EPwm2Regs.AQCSFRC.bit.CSFA = FORCE_LOW;
EPwm2Regs.AQCSFRC.bit.CSFB = FORCE_HIGH;

EPwm2Regs.CMPA.half.CMPA = 0;
EPwm2Regs.CMPB= 0;

//配置比较动作模块
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm2Regs.AQCTLA.bit.CAD = AQ_SET;
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwm2Regs.AQCTLB.bit.CBD = AQ_SET;

EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //DB_ACTV_LO;
EPwm2Regs.DBCTL.bit.IN_MODE = DBA_RED_DBB_FED;
EPwm2Regs.DBRED = DB_2US;//DB_1p5US, 1us=90
EPwm2Regs.DBFED = DB_2US;

///////////////////////////////////////////

以上为初始化时的代码,经过测试不同时执行下面两句话时(若只执行其中一句),B为高,A为低,只要同时执行两句,则A为低,B也为低。

EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //DB_ACTV_LO;

而且更奇怪的就是无论我如何改变A B的强制电平(下面两行代码),均无效,即使我屏蔽上面两行代码,始终都是A低,B高!

EPwm2Regs.AQCSFRC.bit.CSFA = FORCE_HIGH;
EPwm2Regs.AQCSFRC.bit.CSFB = FORCE_HIGH;

HeiHei:这几个寄存器都是有写保护的吧,在前后加上EALLOWEDIS试试

/****************************/
// EPWM2A/B
/****************************/
//时基模块
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // Pass through
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;//TB_ENABLE;
EPwm2Regs.TBPHS.half.TBPHS = 0;
EPwm2Regs.TBCTR = 0x0000;
EPwm2Regs.TBPRD = PWM_INV_TBPRD; // 216us
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
//中断模块
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Enable INT on Zero event
EPwm2Regs.ETSEL.bit.INTEN = 1;//PWM2_INT_ENABLE; // Enable INT
EPwm2Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 2nd event

EPwm2Regs.ETSEL.bit.SOCAEN = 1;
EPwm2Regs.ETSEL.bit.SOCASEL = 1; //ZERO
EPwm2Regs.ETPS.bit.SOCAPRD = 1; //1st
//EPwm2Regs.ETPS.bit.SOCACNT = 1; //1st

//配置比较模块
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
//EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_IMMEDIATE;
//EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_IMMEDIATE;
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD; //CC_CTR_ZERO_PRD //CC_CTR_ZERO
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;

EPwm2Regs.AQCSFRC.bit.CSFA = FORCE_LOW;
EPwm2Regs.AQCSFRC.bit.CSFB = FORCE_HIGH;

EPwm2Regs.CMPA.half.CMPA = 0;
EPwm2Regs.CMPB= 0;

//配置比较动作模块
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm2Regs.AQCTLA.bit.CAD = AQ_SET;
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwm2Regs.AQCTLB.bit.CBD = AQ_SET;

EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //DB_ACTV_LO;
EPwm2Regs.DBCTL.bit.IN_MODE = DBA_RED_DBB_FED;
EPwm2Regs.DBRED = DB_2US;//DB_1p5US, 1us=90
EPwm2Regs.DBFED = DB_2US;

///////////////////////////////////////////

以上为初始化时的代码,经过测试不同时执行下面两句话时(若只执行其中一句),B为高,A为低,只要同时执行两句,则A为低,B也为低。

EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //DB_ACTV_LO;

而且更奇怪的就是无论我如何改变A B的强制电平(下面两行代码),均无效,即使我屏蔽上面两行代码,始终都是A低,B高!

EPwm2Regs.AQCSFRC.bit.CSFA = FORCE_HIGH;
EPwm2Regs.AQCSFRC.bit.CSFB = FORCE_HIGH;

jianxing ding:

回复 HeiHei:

AQCSFRC?有写保护?没有吧,试过一样的不行

赞(0)
未经允许不得转载:TI中文支持网 » 不解事件?PWM强制电平不起作用!TMS28062
分享到: 更多 (0)