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.

Error : expected an identifier & expected an expression



Dear all

i was trying to implement a variable duty PWM using deadband sample program. the code i used

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
{
  
    (float) m = 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

}

 

help me with the error elimination

 

Thanks in advance.:)

 

  • Which version of CCS and compiler are you using? In CCS 3.3, you can check this by going to menu Help->About, and it should tell you the version of Code Generation tools.

    Here is a related post that could help with the "expected an identifier" message. If fixing this does not help resolve the other errors, could you attach the complete C source file? I cannot duplicate the errors you mention using the above code snippet. The only minor change I made was the line: m = (float)k*6000;  and the code builds without errors.

  • I am using CCS 3.3 with code generation tool version 5.1.0

    Mam I used the above logic in deadband example program. tried to manipulate it get one of the PWM train as variable. Now 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.

    Mam i have been trying but I could not get any result.

    I also tried this logic:

       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;

    // Clear INT flag for this timer
       EPwm2Regs.ETCLR.bit.INT = 1;

    in 'interrupt void epwmx_isr(void)'.

    but i am not getting any pulses.

    Help me with the loops of operation.

    Regards

  • This new question is not related to the initial question which was regarding why certain compiler errors were being generated. Please post your question to the C2000 device forum as you may get better answers for this question over there.

  • Mam basically i want to control the compare register value. Here in previous posts i tried to do it in a uncontrolled way but for my setup i will be sensing adc signals and calculate compare register values.

    but for that i lack the insight in dealing with this.

    i have posted their also please guide me if possible

    Regards