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.

TMS320F2809: How to lock on PWM in real time?

Part Number: TMS320F2809

I'm using an F2809 ePWM to control 4 switches.  It's UP_DOWN count mode, load on ZERO_PERIOD.  I'm using 2 Pwm channels, say ePwm1a, ePwm1b for 2 switches and ePwm2a and ePwm2b for 2 other switches for 4 total.  I'm trying to lock the state of a PWM channel during certain time periods (as in, Pwm1a is on the entire period and Pwm1b is off the entire period).  Delay needs to be absolutely minimized and I can't have them change states for even a very short time period.  Below is kind of what my code looks like.

Problem is, I'm getting some unexpected behavior at initialization and during some edge cases.  I was reading through the ePWM reference guide spru791f.pdf and in section 2.4.4 it says to only load values into CMPA between 1 and TBPRD-1.  How else am I supposed to lock the PWM port based on the value of the sine wave?

_iq sineWave;
    
if( sineWave > _IQ(0) ) // command **above** 0
    {
        EPwm1Regs.CMPA.half.CMPA = _IQmpy( sineWave, TBPRD);  // sine wave times period
        EPwm2Regs.CMPA.half.CMPA = 0;                                               // lock PWM complimentary ON/OFF
    }
    else // command **below** 0
    {
        EPwm1Regs.CMPA.half.CMPA = 0;                                              // lock PWM complimentary ON/OFF
        EPwm2Regs.CMPA.half.CMPA = _IQmpy( sineWave, TBPRD); // sine wave times period
}