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.

How to use IQmath library in CCS 3.3?

Hi all,

I am trying to use eZdsp 2812 and CCS 3.3 to control a DC-DC converter. I am informed that the IQmath lib would help to reduce computation time cost, but I got compilation error with it. My code defines the extern _iq IL in the GlobalVariable.h and _iq IL before the main(). The compilation error shows that the _iq is undefined. I already added the IQmathLib.h, IQmath.lib and 2802x_IQmath_BootRomsymbols.lib into my project.

Another simple question is that the variables used in ISR have to be extern?

Please help me with those two problems.

He, Siyu

  • Hi Siyu,

    I really don't know why using this library is troubling you. Here's a simplest implementation:

    #include<IQmathLib.h> /* Header file for IQ math routine */
    _iq in1 out1;
    _iq28 in2 out2;
    void main(void )
    {
    in1 = _IQ(1.5);
    out1 = _IQdiv(_IQ(1.0), in1);
    in2 = _IQ28(1.5);
    out2 = _IQ28div(_IQ28(1.0), in2);
    }

    Yes using global variables would be recommended while using ISRs.

    Regards,

    Gautam

  • Hi,

    I tried the example project come along with controlSuit and it works well. I think the problem might be using it in ISR.

    He, Siyu

  • Ohk...you're problem now is implementing IQmath in an ISR, right. Can you attach a screenshot of the error while implementing in the same way?

    Regards,

    Gautam

  • I defined the

    _iq test;

    as a global variable before main() in main.C. And define

    extern _iq test;

    in GloblaVariable.h .

    The compilatoin errors is shown below:

    Each .C file is detected out a identical error.

    He, Siyu

  • Hi again,

    You don't have to include : extern _iq test;  in GloblaVariable.h

    Just in main.c is enough.

    Also please take into consideration and also what I've been meaning to say since a long time is:

    The error _iq is undefined means the compiler is not able to detect this datatype which in turn means that this datatype is inaccessible.

    Did you try declaring _iq  in the ISR itself?

    Regards,

    Gautam

  • Hi,

    (1)I defined extern _iq test in GlabalVariable.h and added #include "IQmathLib.h" in DefaultIsr.C. The compilation went through. I am trying to redefine the GLOBAL_Q and MATH_TYPE, it seems like they should be defined in IQmathLib.h not in main.C. Am I right?

    (2)The computation results is still in IQ format, before I use it to assign to output, do I need to convert it back to float?

    (3)I added test and _IQ(test) in watch window to view value. It turns out that the test would change but the_IQ(test) is not changed, I have to re-type _IQ(test) into watch window to refresh. How to do with it?

    (4)If I want to do  _iq20 test = IQdiv4(_iq15(A)), do need to converter the right side to _iq20, _iq20 test = _iq20(IQdiv4(_iq15(A)))?

    He, Siyu

  • Hi,

    As per my info, for computations datatypes have to be same for eg. if you define _iq20 based variables; computation variables and the result variable has to be of type _iq20.

    Regards,

    Gautam

  • Hello,

    there are some fucntions with arguments having different Qs. For exaple _IQNmpyIQX.

    Check page 53 of IQMathQuickStart guide (attached in this post).

    IQmath_Quickstart.pdf
  • Hi,

    It seems like the CCS 3.1 and 3.3 have this kind of bug that _IQ(variable) in watch window can not update by itself, I have to do it manually. And thanks for your documents, I am more familiar with IQmath now.

    Thank you.

    He, Siyu