This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

2803X/2806X系列MCU 内部比较器(comp)触发EPWM问题

Other Parts Discussed in Thread: CONTROLSUITE

问题是这样的:

我想通过内部的模拟比较器

当外部电压高于内部DAC设定值的时候来使PWM输出信号置位

我尝试很多次 无论是one-shot 或者 cycle-by-cycle 都有一个问题

比如 我初始设定PWM信号占空比50%输出,

内部设定的数值为512(1.5V) ,当比较器输出为低的时候触发DCAEVT 使pwm信号置位  cycle-by-cycle 模式

但是 我输入电压从3V开始降,大概在2.2V左右输出的pwm信号就开始跳动(偶尔还是50%,偶尔置位)

从2.2V到1.5V之间 越往下跳动的越厉害(就是PWM置位的时间越多,50%占空比的时间越少)

当小于1.5V的时候能实现PWM信号的完全置位;

同样 设定为one-shot模式的时候,电压从3V开始降 降到2.2V左右的时候 PWM信号就置位了。

这个bug困扰了我很久,不知道是实验板的问题 还是我程序设置有问题。

希望有人能够解答,感激不尽~

————————————————————————————————————————

我使用的是F28069

下面附上自己的程序主要部分,希望有人能够帮助解决~

EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; //Comparator shares the internal BG reference of the ADC, must be powered even if ADC is unused
Comp2Regs.COMPCTL.bit.COMPDACEN = 1; //Power up Comparator 1 locally
Comp2Regs.COMPCTL.bit.COMPSOURCE = 0; //Connect the inverting input to the internal DAC
Comp2Regs.COMPCTL.bit.SYNCSEL = 0;
Comp2Regs.DACVAL.bit.DACVAL =dac_value; //Set DAC output to midpoint
EDIS;

//===============================================================
// PWM-DAC & TZ Configuration
//===============================================================
#define period 6000 
// Time-base registers
EPwm1Regs.TBPRD = period; // Set timer period, PWM frequency = 1 / period
EPwm1Regs.TBPHS.all = 0; // Time-Base Phase Register
EPwm1Regs.TBCTR = 0; // Time-Base Counter Register
EPwm1Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // Set Immediate load
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count-up mode: used for asymmetric PWM
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;

// Setup shadow register load on ZERO

EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero

// Set Compare values

EPwm1Regs.CMPA.half.CMPA = duty_cycle_A; // Set duty 50% initially, ~1.5 V

EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on event A, up count


EALLOW;
//================================================
// Configure digital compare event (DCAEVT2)
//================================================
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP2OUT; // DCAH = Comparator 2 output
EPwm1Regs.DCTRIPSEL.bit.DCALCOMPSEL = DC_TZ2; // DCAL = TZ2
EPwm1Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_LOW; // DCAEVT2 = DCAH low(will become active as Comparator output goes low)
EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT2; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC; // Take async path

// Enable DCAEVT2 and DCBEVT2 are cycle-by-cycle trip sources
// Note: DCxEVT1 events can be defined as one-shot.
// DCxEVT2 events can be defined as cycle-by-cycle.

EPwm1Regs.TZSEL.bit.DCAEVT2 = 1; // cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCBEVT2 = 1; // cycle-by-cycle.


EPwm1Regs.TZCTL.bit.DCAEVT2 = TZ_FORCE_HI; // EPWM1A will go high
EDIS;

————————————————————————————————————

PS  ControlSUITE 里面的很多例子我都看过了

也拿出来调试过 都是这个问题