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

TMS320F28035: 28035做逆变时,正半周和负半周切换时DSP莫名其妙地复位,不知道什么原因!

Part Number:TMS320F28035

您好,我在用28035在做单相逆变器,来生成正弦波!正半周时EPWM1A 与 EPWM2B 导通,负半通时EPWM1B与EPWMA导通。

void InitEPWM1()
{
//PWM1 模块配置
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.PHSDIR = TB_DOWN;
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Synchronization Output Select. Time-base counter equal to zero (TBCTR = 0x0000)
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

// Setup shadowing
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

EPwm1Regs.TBPRD = PWM_DC_TO_AC_PERIOD; // Set timer period
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter

EPwm1Regs.CMPA.half.CMPA = nMainDuty;
EPwm1Regs.CMPB = PWM_DC_TO_AC_ADC;

// Set actions
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // 置高
EPwm1Regs.AQCTLA.bit.CAD = AQ_SET; // 置低

EPwm1Regs.AQCTLB.bit.CAU = AQ_SET; // 置低
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET; // 置低

// Active Low PWMs – Setup Deadband
/* EPwm1Regs.DBCTL.bit.HALFCYCLE = 1;
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_LOC;
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm1Regs.DBRED = 80;
EPwm1Regs.DBFED = 80;*/

// 触发ADC采样
EPwm1Regs.ETSEL.bit.SOCBEN = 1;
EPwm1Regs.ETSEL.bit.SOCBSEL = ET_CTRU_CMPB;
EPwm1Regs.ETPS.bit.SOCBPRD = ET_1ST;

EALLOW;
EPwm1Regs.TZFRC.bit.OST = 1;
EDIS;
}

void InitEPwm2( void )
{
EPwm2Regs.TBPRD = PWM_DC_TO_AC_PERIOD; // Set timer period
EPwm2Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm2Regs.TBCTR = 0x0000; // Clear counter

//PWM2 模块配置
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Disable phase loading
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE; // Synchronization Output Select. Time-base counter equal to zero (TBCTR = 0x0000)
EPwm2Regs.TBCTL.bit.PHSDIR = TB_DOWN;
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;

// Setup shadowing
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;

EPwm2Regs.CMPA.half.CMPA = nMainDuty;
EPwm2Regs.CMPB = 580;

// Set actions
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // 置低
EPwm2Regs.AQCTLA.bit.CAD = AQ_SET; // 置低

EPwm2Regs.AQCTLB.bit.CAU = AQ_CLEAR; // 置高
EPwm2Regs.AQCTLB.bit.CAD = AQ_SET; // 置高

// Active Low PWMs – Setup Deadband
/* EPwm2Regs.DBCTL.bit.HALFCYCLE = 1;
EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_LOC;
EPwm2Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm2Regs.DBRED = 80;
EPwm2Regs.DBFED = 80;*/

EALLOW;
EPwm2Regs.TZFRC.bit.OST = 1;
EDIS;
}

然后在中断程序中进行切换,

正半周切换代码

EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // 置高
EPwm1Regs.AQCTLA.bit.CAD = AQ_SET; // 置低
EPwm1Regs.AQCTLB.bit.CAU = AQ_SET; // 置低
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET; // 置低
// EDIS;

// EALLOW;
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // 置低
EPwm2Regs.AQCTLA.bit.CAD = AQ_SET; // 置低
EPwm2Regs.AQCTLB.bit.CAU = AQ_CLEAR; // 置高
EPwm2Regs.AQCTLB.bit.CAD = AQ_SET; // 置低

负半周切换代码

EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // 置高
EPwm1Regs.AQCTLA.bit.CAD = AQ_SET; // 置低
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; // 置低
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET; // 置低
// EDIS;

// EALLOW;
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR; // 置低
EPwm2Regs.AQCTLA.bit.CAD = AQ_SET; // 置低
EPwm2Regs.AQCTLB.bit.CAU = AQ_SET; // 置高
EPwm2Regs.AQCTLB.bit.CAD = AQ_SET; // 置低

在测试的时候,发现正半周向负半周切换的时候,会导致DSP复位,也不知道什么原因!

wang feng:

查到原因了,是电源不稳!

,

Yale Li:

好的

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28035: 28035做逆变时,正半周和负半周切换时DSP莫名其妙地复位,不知道什么原因!
分享到: 更多 (0)