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.

CCS/TMDSCNCD28035: CSS _IQ to Float

Part Number: TMDSCNCD28035


Tool/software: Code Composer Studio

I want to multiply two numbers, in some cases it doesn't work correct.

In this case it works good :

_iq a=_IQ(10.0);

float32 b=2.5;

x = _IQtoF(_IQmpy(_IQ(b), a)); // result in float 25

But in this case it doesn't work correct

float32 q=0.0; _iq

y1=_IQ(1.5);

q =_IQtoF(_IQmpy(_IQ(100),y1)); //  The result shoud be 150 but in viewwatch is it -1026293761

I tried to vary the IQ for example _IQ20(100), _IQ21(100) ..... but I don't get the right result.

What needs to be changed in the code

Thank you for the answer

  • Hi,

    Valentin Vanyo said:
    float32 q=0.0; _iq

    What is _iq doing here?

    Valentin Vanyo said:
    y1=_IQ(1.5);

    How is y1 initialized? It should be _iq y1; somehow _iq got shifted to above line.

    Valentin Vanyo said:
    q =_IQtoF(_IQmpy(_IQ(100),y1)); //  The result shoud be 150 but in viewwatch is it -1026293761

    Try with _IQ(100.0)

    Regards,

    Gautam

  • Valentin,

    Regarding the last part, you cannot represent 150 in IQ14 format. The 7 integer bits restrict you to +128 max. If you attempt to multiply 100 by 1.5 there will be an overflow and you'll get -1026293761, as you observe.

    You need to select a differeny GLOBAL_Q in IQmathLib.h, or use a locally different IQ format and IQmpy function.

    Regards,

    Richard