F28335 ADC模块触发用EPWM的设置错误
[复制链接]
想利用epwm触发ADC采样,但程序一直有错,四处寻找找到一个可行的例程,经过控制变量排除错误,问题出在触发用EPWM的配置,用如下第一段配置程序可行,第二段不可行,但反复对比百思不得其解这两段配置程序有啥区别,为什么第一段可行第二段不可行,望前辈大牛帮助下
//可行
void InitEPwm3Example()
{
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm3Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
EPwm3Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from PER
EPwm3Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
EPwm3Regs.TBPRD = 1875;
EPwm3Regs.CMPA.half.CMPA = 900;
//EPwm1Regs.CMPB = 4500;
EPwm3Regs.TBPHS.all = 0x00000000;
// EPwm3Regs.AQCTLA.bit.PRD = AQ_TOGGLE; // Toggle on PRD
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
EPwm3Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm3Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR = Zero
EPwm3Regs.AQCTLA.bit.ZRO = 0;
EPwm3Regs.AQCTLA.bit.CAU = 1;
EPwm3Regs.AQCTLA.bit.CAD =2;
// EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET;
// EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR;
// TBCLK = SYSCLKOUT
EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0;
EPwm3Regs.TBCTL.bit.CLKDIV = 0;
// EPwm1TimerDirection = EPWM_TIMER_UP;
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
}
/*
//不可行错误未知
void InitEPwm3Example()
{
EPwm3Regs.ETSEL.bit.SOCAEN=1;
EPwm3Regs.ETSEL.bit.SOCASEL=2;
EPwm3Regs.ETPS.bit.INTPRD =1;
EPwm3Regs.TBPRD = 3750;
EPwm3Regs.TBPHS.half.TBPHS = 0x0000;
// EPwm3Regs.TBCTR = 0x0000;
EPwm3Regs.CMPA.half.CMPA =933;
EPwm3Regs.CMPB = 933;
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;
EPwm3Regs.AQCTLA.bit.CAU = AQ_SET ;
EPwm3Regs.AQCTLA.bit.CAD = AQ_CLEAR;
EPwm3Regs.AQCTLB.bit.CBU = AQ_SET;
EPwm3Regs.AQCTLB.bit.CBD = AQ_CLEAR;
// EPwm2Regs.ETSEL.bit.INTSEL=4; //递增事件产生信号
EPwm3Regs.ETPS.bit.INTPRD =1;
EPwm3Regs.ETSEL.bit.SOCAEN=1;
EPwm3Regs.ETSEL.bit.SOCASEL=2;
}
*/
|