Hi,
this time I try to use a DCOMP.
EADC0 gets the Output voltage (divided) and is used to Close the control Loop. To prevent the unloaded flyback module from generating too high voltages, DCOMP0 should fire if the Limit is exeeded and stop the DPWM.
I followed the samples (Cyclone labs) and do this with ACOMP_F and AD06 Input. Works. But why using two Inputs for that function, DCOMP0 is the better solution, I thought.
Here my config:
void init_HW_OV_Protection_DComp(void)
{
FaultMuxRegs.DCOMPCTRL0.bit.FE_SEL = 0; // FrontEnd0, absolute data
FaultMuxRegs.DCOMPCTRL0.bit.COMP_POL = 1; // Fires if input is greater
FaultMuxRegs.DCOMPCTRL0.bit.THRESH = 500; //Threshold, 1.5625mV/bit 500 .. 781mV
FaultMuxRegs.DCOMPCTRL0.bit.CNT_THRESH = 2; // Observes CNT_THRESH values, max. 255
FaultMuxRegs.DCOMPCTRL0.bit.CNT_CONFIG = 0; // 0 .. good samples clear the counter, 1 .. good samples decrement the counter
FaultMuxRegs.DCOMPCTRL0.bit.INT_EN = 0; // Generate interrupts
FaultMuxRegs.DCOMPCTRL0.bit.COMP_EN = 1; // Enable comperator
FaultMuxRegs.DPWM0FAULTDET.bit.PWMA_DCOMP0_EN = 1; // Root DCOMP0 output to DPWM0A fault input.
}
Well, Interrupt is disabled, I know!!!
Now I check FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0 and it was 0, after exeeding the Limit it is 1, perfect.
I also checked out the ..CNTSTAT and I get 0 or 2, perfect.
I toggled the CNT_CLR bit and this clears also FaultMuxRegs.FAULTMUXRAWSTAT.bit.DCOMP0, perfect.
Now I enabled the Interrupt. After exeeding the Limit, the DPWM still running but the Debugger crashes. I have to restart the USB-to-GPIO box, and the Digital Fusuin GUI and Flash the program.
???
I also read the INTSTAT (
if ( FaultMuxRegs.FAULTMUXINTSTAT.bit.DCOMP0 == 1 ) ov_state ++; //OVP) as I have done with ACOMP_F before, nothing helps.
Whats wrong?
By the way. After implementing light load mode, ACOMP_F didn't stop the DPWM, but this behavior is under further Investigation.
Thanks a lot for helping.
With best regards
Gerhard