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.

CCSTUDIO-C2000: Code for converting between Q format and float format in ccs

Part Number: CCSTUDIO-C2000


How to convert between Q format and float format in ccs? What is the code format? The following code is wrong:

The variables "Notch_parameters.r_k" and "Notch_parameters.notch_outvoltage" are float type, and the variable "iv.vbus_filtered" is an unsigned 32-bit Q18,

Q format converted to float type:Notch_parameters.r_k=float(iv.vbus_filtered)/(262144)

Convert float type to Q format:int(Notch_parameters.notch_outvoltage*(4096))

May I ask how to correctly convert in CCS?