TI中文支持网
TI专业的中文技术问题咨询交流网站

tms32f28035中的模拟比较器的中断触发问题

各位老师好

请问下,我在使用tms32f28035中的模拟比较器时,同相输入A为外部输入信号iL,反向输入B为DACVAL基准。

期望:当iL < DACVAL时,产生时间DCAEVT1,然后产生DCAEVT1.inter中断信号,中断产生的过程如下图中的红色路径:

 

之后,经过触发区子模块产生EPWMxTZINT中断。如下图:

 

问题:无论我DACVAL设为何值都会触发EPWMxTZINT中断,为什么?明明iL > DACVAL时,还是会触发EPWMxTZINT中断。并且,我观察comp1out,发现输出为50Hz的方波,会什么会这样?

/************************epwm程序和comp1的初始化程序************************/

void InitEPwm(void)

{

         InitEPwmGpio();

 

//————–EPWM1——————————-

         EPwm1Regs.TBPRD = 3000;                          //最小的开关频率20k

         EPwm1Regs.CMPA.half.CMPA = 120;                    // the number has no effect?

//      EPwm1Regs.CMPB = 0;

         EPwm1Regs.TBCTR = 0;

         EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;                         // Count up mode

         EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE;                     // phase enable

         EPwm1Regs.TBPHS.half.TBPHS = 3000;

         EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;      

         EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;                // enable

         EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;                // TBCLK = 1/60M

         EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

         EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;

         EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;

 

   EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;                       // clear PWM1A on CAU

   EPwm1Regs.AQCTLA.bit.PRD = AQ_SET;                                       // set PWM1A on CAD

// EPwm1Regs.AQCTLB.bit.CAU = AQ_SET;                         // Clear PWM1B on CAU

// EPwm1Regs.AQCTLB.bit.PRD = AQ_CLEAR;                       // Set PWM1B on CAD

   EPwm1Regs.ETSEL.bit.INTSEL= ET_CTRU_CMPA;

   EPwm1Regs.ETSEL.bit.INTEN = 1;

   EPwm1Regs.ETPS.bit.INTPRD       = ET_1ST;                          // Generate pulse on 1st event

 

         EALLOW;

 

         GpioCtrlRegs.AIOMUX1.bit.AIO2 = 2;

         SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 1;   // Enable clock to the Comparator 1 block 以便修改DAC基准

         Comp1Regs.COMPCTL.bit.COMPDACEN = 1;          // Power up Comparator 1 locally

         Comp1Regs.COMPCTL.bit.COMPSOURCE = 0; // Connect the inverting input to the internal DAC

         Comp1Regs.DACVAL.bit.DACVAL = 589;                                 // Set DAC output

         Comp1Regs.DACCTL.bit.DACSOURCE = 0;  // 0-DACVAL;1-Internal ramp for slope compensation

   AdcRegs.COMPHYSTCTL.bit.COMP1_HYST_DISABLE = 1;          // Hysteresisdisable

   Comp1Regs.COMPCTL.bit.CMPINV=0;         // 0: Output of comparator,1: Inverted

   Comp1Regs.COMPCTL.bit.SYNCSEL = 0;      // Asynchronous version of Comparator output

         EPwm1Regs.DCTRIPSEL.bit.DCALCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output

         EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAL_LOW; // DCAEVT1 = DCAL low(will become active as Comparator output goes low)

         EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1;   // DC_EVT1

         EPwm1Regs.TZEINT.bit.DCAEVT1 = 1;

 

         EDIS;

//——————–死区设置—————————-

         EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;            //将A作为下降边沿和上升边沿延迟

         EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;            //输出不反相

         EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;

         EPwm1Regs.DBFED = 60;              //死区下降沿延迟60个TBCLK周期

         EPwm1Regs.DBRED = 60;   //死区上升沿延迟60个TBCLK周期

}

 

/************************EPWM1TZINT中断程序************************/

__interrupt void EPWM1_TZINT_ISR(void)   // EPWM-1

{

// Insert ISR Code here

//

// To receive more interrupts from this PIE group, acknowledge this interrupt

// PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;

 

// Next two lines for debug only to halt the processor here

// Remove after inserting ISR Code

         EALLOW;

 

         EPwm1Regs.TZCLR.bit.DCAEVT1 = 1;

         EPwm1Regs.TZCLR.bit.INT = 1;

 

         EDIS;

 

         PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;

}

Annie Liu:

为更加有效地解决您的问题,我们建议您将问题发布在E2E英文技术论坛上https://e2e.ti.com/support/microcontrollers/c2000/f/171,将由资深的工程师为您提供帮助。我们的E2E英文社区有TI专家进行回复,并得到全球各地工程师的支持,分享他们的知识和经验。

赞(0)
未经允许不得转载:TI中文支持网 » tms32f28035中的模拟比较器的中断触发问题
分享到: 更多 (0)