Good evening,
I would like to measure the Ton period generated by an analog comparator, reset by the CRT=0 event of a PWM, using the DCCAP register of the Digital Compare Submodul of that PWM.
The problem is that the description of the Capture Control Logic is not clear and trying to configure all paths is very hard. Actually I tried, but I did not have success.
In the following there is the code I used:
//Comparator configuration
EALLOW;
CpuSysRegs.PCLKCR14.all |= 1
Cmpss2Regs.COMPCTL.bit.COMPHSOURCE = 0;
Cmpss2Regs.COMPCTL.bit.COMPHINV = 0;
Cmpss2Regs.COMPCTL.bit.CTRIPHSEL = 3;
Cmpss2Regs.COMPCTL.bit.CTRIPOUTHSEL = 3;
Cmpss2Regs.COMPCTL.bit.ASYNCHEN = 0;
Cmpss2Regs.COMPCTL.bit.COMPLSOURCE = 0;
Cmpss2Regs.COMPCTL.bit.COMPLINV = 0;
Cmpss2Regs.COMPCTL.bit.CTRIPLSEL = 0;
Cmpss2Regs.COMPCTL.bit.CTRIPOUTLSEL = 0;
Cmpss2Regs.COMPCTL.bit.ASYNCLEN = 0;
Cmpss2Regs.COMPHYSCTL.bit.COMPHYS = 2;
Cmpss2Regs.COMPSTSCLR.bit.HSYNCCLREN = 1;
Cmpss2Regs.COMPDACCTL.bit.DACSOURCE = 1;
Cmpss2Regs.COMPDACCTL.bit.RAMPSOURCE = 1;
Cmpss2Regs.COMPDACCTL.bit.SELREF = 1;
Cmpss2Regs.COMPDACCTL.bit.RAMPLOADSEL = 0;
Cmpss2Regs.COMPDACCTL.bit.SWLOADSEL = 1;
Cmpss2Regs.COMPDACCTL.bit.FREESOFT = 0;
Cmpss2Regs.RAMPMAXREFS = 0;
Cmpss2Regs.RAMPDECVALS = 0;
Cmpss2Regs.RAMPDLYS.bit.DELAY = 0;
Cmpss2Regs.CTRIPLFILCTL.bit.SAMPWIN = 0;
Cmpss2Regs.CTRIPLFILCTL.bit.THRESH = 1;
Cmpss2Regs.CTRIPLFILCTL.bit.FILINIT = 0;
Cmpss2Regs.CTRIPLFILCLKCTL.bit.CLKPRESCALE = 0;
Cmpss2Regs.CTRIPHFILCTL.bit.SAMPWIN = 31;
Cmpss2Regs.CTRIPHFILCTL.bit.THRESH = 19;
Cmpss2Regs.CTRIPHFILCTL.bit.FILINIT = 0;
Cmpss2Regs.CTRIPHFILCLKCTL.bit.CLKPRESCALE = 0;
Cmpss2Regs.COMPLOCK.bit.COMPCTL = 0;
Cmpss2Regs.COMPLOCK.bit.COMPHYSCTL = 0;
Cmpss2Regs.COMPLOCK.bit.DACCTL = 0;
Cmpss2Regs.COMPLOCK.bit.CTRIP = 0;
Cmpss2Regs.COMPCTL.bit.COMPDACE = 1;
EDIS;
/* CMPSS modules PWM xbar activation: CMPSS all configured*/
EALLOW;
EPwmXbarRegs.TRIP5MUX0TO15CFG.bit.MUX2 = 0; /* Select CMPSS2.CTRIPH to pass to TRIP 5 */
EPwmXbarRegs.TRIP5MUXENABLE.bit.MUX2 = 1; /* Enable MUX2 to pass CMPSS2.CTRIPH to TRIP 5 */
EDIS;
//EPWM
EALLOW;
EPwm2Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_HI; /* DCAEVT1 = DCAH High, DCAL disabled */
EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = e_DC_TRIPIN5; /* DCAH = TRIPIN5 */
EPwm2Regs.DCFCTL.bit.SRCSEL = 0; /* Filter Block Signal Source Is DCAEVT1 Signal */
EPwm2Regs.DCFCTL.bit.BLANKE = 1; /* Blanking window is enable */
EPwm2Regs.DCFCTL.bit.BLANKINV = 0; /* Blanking window not inverted */
EPwm2Regs.DCFCTL.bit.PULSESEL = 1; /* Pulse Select For Blanking & Capture Alignment TBCTR = 0x00 */
EPwm2Regs.DCCAPCTL.bit.CAPE = 1; /* TBCTR Counter Capture DIsable */
EPwm2Regs.DCCAPCTL.bit.SHDWMODE = 1; /* Shadow Mode disabled */
EPwm2Regs.DCCAPCTL.bit.CAPMODE = 0; /* No latch */
EPwm2Regs.DCFOFFSET = 0; /* Blanking Window Offset */
EPwm2Regs.DCFWINDOW = 0; /* Blanking Window Width */
EPwm2Regs.DCAHTRIPSEL.all = 0; /* NO Trip Input selected as combinational ORed input */
EPwm2Regs.DCALTRIPSEL.all = 0; /* NO Trip Input selected as combinational ORed input */
EPwm2Regs.DCBHTRIPSEL.all = 0; /* NO Trip Input selected as combinational ORed input */
EPwm2Regs.DCBLTRIPSEL.all = 0; /* NO Trip Input selected as combinational ORed input */
EPwm2Regs.HRPCTL.bit.PWMSYNCSEL = 1; /* PWMSYNC Source Select Bit: PWMSYNC = CNT_zero signal pulse. This Sync is used by COMP*/
EDIS;
It seems that the register EPwm2Regs.DCCAP samples always 1, even if the comparator is switching (low to high) @ greater Ton.
Could you please tell me where is the error?
If the blanking is disabled (actually I would't need blanking to measure the Ton), the input of the 'AND' gate in the figure is always one or always 0?
Thank you in advance.