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.

Disable a PWM which is in Comparator cycle-by-cycle mode

Hello!

I have a PWM where the pulse width is controlled by a comparator. TZCTL[TZA] forces low and TZCTL[TZB] forces high. The dead band is generated by an external circuit.

In case of an error (ADC value, etc.) I want to disable the PWM with a Trip Zone one shot event. Is is is sufficient to configure TZCTL just before the OST Event, or is there some timing restrictions. Will the below code work?

Is there another elegant way to disable the PWM?

-Thomas

// start PWM
EALLOW;
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO;
EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_HI;
EPwm1Regs.TZCLR.bit.OST = 1;
EDIS;

// Stop PWM
EALLOW;
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO;
EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO;
EPwm1Regs.TZFRC.bit.OST = 1;
EDIS;

  • Hi Thomas,

    There is one other approach which I might recommend:
    Change your PWM to GPIO functionality when you wish to turn the PWM off via the GPIO mux.  You can preconfigure the GPIO to be an output which is set to low and merely change the mux when you desired to turn off the PWM.  You'd then change it back to a PWM (carefully, ideally with 0% duty cycle) when you want the PWM enabled again.


    Thank you,
    Brett