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.

Varying PWM

Other Parts Discussed in Thread: CONTROLSUITE

Dear all

I am using deadband example for getting a variable PWM. I was trying with:

PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
 A1=A1+TWO_PI_div20;
if(A1 >=TWO_PI)
A1=0.0;
B=sin(A1);
B=6000-0.8*B*6000;
C=(Uint32) B;

EPwm1Regs.CMPA.half.CMPA=C;

but its not working. My doubt is there are 3 loops. one is the main program, second is InitEPwmxExample, and third is 'interrupt void epwmx_isr(void)'. Where should i place the logic to update my compare value after every pulse.

My compare register value is not getting updated that's why i manot be getting the PWM pulses.

Earlier I tried with even simpler logic:

float k=0.1;

float m=0.0;          //intialization in the main program                                              

                                                                                                         //for both the intialization statements expected an identifier error popped

//since i need to see one of the PWM's varying in duty cycle so the code below

if ( k < (float)0.96 )                                              //error expected an expression popped
{
  
     m = (float) k*6000;                                        //error expected an expression popped
    EPwm3Regs.CMPA.half.CMPA = m;          //error expected an expression popped
  
    k= k+0.05;                                                        //error expected an expression popped
}
else
{

k=0.1;                                                                 //error expected an expression popped

}

this logic also did not work.

Maybe i am placing the logic in the wrong loop. either it is so slow that the compare register value is not getting updated.

Please help me in this.

Basically my doubt is in adjusting the compare register value.

Regards