I attempts to make current protection in the pulse converter using a fault extension in atxmega32e5. I was able to run a fault extension system. To the PWM output, I connected the diode to the "+" input of the comparator potentiometer, and to the input "-" the internal voltage divider. When the voltage on the potentiometer is greater than the divider, the diode goes out, and when the potentiometer is less than the voltage, the diode is burning, which is how it should be.
But when I applied this program to my impulse drive program, in the flyback topology (schematic in the appendix), this security does not work. Interestingly, when I change the value of the voltage divider from 0 to 30, the output voltage of the inverter slowly increases to the setpoint, and when it loads the voltage drops to about 2 V. When the value of the divider is greater than 30, ie, It works as if there was no program code for the fault extension. For the parameters of the inverter: the maximum instantaneous current on the primary side is about 12 A, so the protection should work when the bypass voltage is about 0.3V. Uwe = 17 V DC, Uwy = 40 V DC. I made a layout on a PCB. I have implemented the PI programmer and, as far as the inverter program itself is concerned, everything works very well in static and dynamic conditions.
I enclosed the program code in the attachment. I am sorry for my bad english.