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.

TMS320F28335: Variable initialization (Syntax/ Building Error) float, double, int32

Part Number: TMS320F28335


Dear TI members,

I am working on one code (no building errors). Now I am having building errors when I added some lines in my code: Line 293, Line 295, Line 299 and Line 300 (see Picture 1) during initializing variables.  The variables are initialized as you can see in Picture 2

Picture 1:

Picture 2:

Please suggest accordingly.

Thanks

Regards

Arsalan

  • Arsalan, 

    You have not defined the variables NEW_Duty and NEW_Period. (or have not included the definitions in the screenshots, in which case, do let me know)

    Thanks.

  • Hi Sahil,

    Thanks for your reply.

    Thanks for correcting me. Also, the errors have been removed. and it was also resolved by using a double means not an integer or Unit32 number but it is resolved through a kind of float number(double). Now the problem is in Picture 2--.> Line 304 & Line 305. Variables NEW_Period & NEW_Duty are double and I want to make or round to them as an int32 value e.g 1032.655 to 1032. because I will send this number to my ePWM TBPRD register  which is a 32bit integer number. (Like you see Picture 1: PWM_Duty, PWM_Period....). 

    Could you please suggest how I can round the double NEW_Period & NEW_Duty into a int32 number?

    Picture1:

    Picture 2:

    Please suggest accordingly

    Thanks

    Regards

    Arsalan

  • how I can round the double NEW_Period & NEW_Duty into a int32 number?

    You can just define the variables as int32, and when you try to write the float variable to the int32 variable, it will truncate the numbers after the decimal point. The compiler will issue a warning, but it is safe to ignore it.

    Thanks.