专家,您好:
我想用28035的比较器做以下功能(同一个比较器交替控制PWM1与PWM2):
50Hz的交流正半周在1A口信号>DACVAL时,封波PWM2A;
50Hz的交流负半周在1A口信号<DACVAL时,封波PWM1A;
交流过零检测没有问题,DC模块的配置没有问题,自己测试过!
但是实现上述功能时,没有成功。找不出问题所在,请专家帮忙!谢谢
代码如下:
交流正半周10ms
#if 1
EALLOW;
//EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP1OUT;
//DC--TZ
EPwm1Regs.TZSEL.bit.DCBEVT2 = 0; //disable DCAEVT1 as cbc source for this ePWMmodule
EPwm1Regs.TZSEL.bit.DCAEVT2 = 0;
// Define an event (DCAEVT1) based on TZ1
EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm2Regs.TZSEL.bit.DCAEVT2 = 1; //Enable DCAEVT1 as cbc source for this ePWMmodule
EPwm2Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_HI;//TZ_DCAH_HI;//TZ_DCAH_LOW; // DCAEVT1 = DCAH high(will become active as Comparator output goes low)
//Enable Interrupt generation;
Comp1Regs.DACVAL.all= 330;//320;//372; //_1.2V
EDIS;
#endif
交流负半周10ms
EALLOW;
//DC--TZ
EPwm2Regs.TZSEL.bit.DCAEVT2 = 0; //disable DCAEVT1 as cbc source for this ePWMmodule
EPwm2Regs.TZSEL.bit.DCBEVT2 = 0;
// Define an event (DCAEVT1) based on TZ1
EPwm1Regs.DCTRIPSEL.bit.DCBLCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm1Regs.TZSEL.bit.DCBEVT2 = 1; //Enable DCAEVT1 as cbc source for this ePWMmodule
EPwm1Regs.TZDCSEL.bit.DCBEVT2 = TZ_DCAH_LOW;//TZ_DCAH_HI;//TZ_DCAH_LOW; // DCAEVT1 = DCAH high(will become active as Comparator output goes low)
//Enable Interrupt generation;
Comp1Regs.DACVAL.all= 300;//320;//372; //_1.2V
EDIS;
//DC初始化代码:
EALLOW;
AdcRegs.COMPHYSTCTL.bit.COMP1_HYST_DISABLE = 1; //Hysteresisdisable
Comp1Regs.COMPCTL.bit.CMPINV=0; //0: Output of comparator,1: Inverted 比较器输出没有翻转
Comp1Regs.COMPCTL.bit.COMPSOURCE=0; //connected to internal DAC 连接到内部DAC
Comp1Regs.COMPCTL.bit.SYNCSEL = 0; //Asynchronous version of Comparator output //异步操作
Comp1Regs.COMPCTL.bit.COMPDACEN=1; //for test
Comp1Regs.DACCTL.bit.DACSOURCE=0;
//Comp3Regs.DACVAL.all= 744; //_2.4V--1A----
//Comp1Regs.DACVAL.all= 350;//320;//372; //_1.2V
EDIS;
盼复!!