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: IQ library and TMS320F28030

Other Parts Discussed in Thread: TMS320F28030

Tool/software: Code Composer Studio

Hello,

I have been working with TMS320F28030.

I have two data that i need to multiply them in IQ format but i couldnot find an IQ value which gives me correct values.

what i did so far is;

//defines 

#define GLOBAL_Q 16 // changed 16 to few other values to test
long GlobalQ = GLOBAL_Q;

#define res16 0.0000762939453125 //  = 5/2^16
#define data 0x9B76 //16 bit data

_iq res16_iq;
_iq data_iq;

in main loop;

res16_iq = _IQ(res16);
data_iq = _IQ(data);

when i change GLOBAL_Q 16 to

GLOBAL_Q 15 or less i get correct value for data_iq but wrong value for res16_iq,

GLOBAL_Q 16 or more i get correct value for res16_iq but wrong value for data_iq.

1) is there any way to multiply data_iq and res16_iq in an _IQ value? such like _IQmpy(data_iq, res16_iq)

2) and for the project when i debug it with flash i can see correct values of _IQ but when i try without flash _IQ values appears to be different then expected.

  • Hello Harun,

    In IQ16 you have 15 bits of signed integer range, so you cannot represent 0x9B76 = 39,798. It works with IQ15 because there are enough bits to represent the number. You should get a compiler warning about this on the line
    data_iq = _IQ(data);

    This is the trade-off with any fixed point machine. The IQ math library helps to manage numerical range & resolution, but it cannot change the number of bits available to represent numbers. The best solution here is to locally use IQ15 for tthe multiplication and convert the result back to IQ16 afterwards. You will lose resolution on "res16", but at least you can represent the result.

    Alternatively, you could of course use floating-point, either with the RTS library on this device (with the penalty of much increased computation time), or by migrating to a floating-point device such as F28069, in which case the problem would go away.

    Regarding the library functions not working from flash, can you check where you have the "IQmath" section mapped in your linker command file? See p.16 of the IQ math library user's guide for an example of a .cmd file for F28035. Your sections should look like these, but with IQmath in a flash program memory section.

    Regards,

    Richard