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.

IQmath library trigonometric function

Hi,
I am working on the beagleboard C4 (with c64x+ fixed-point processor). Using the _IQsin function from IQmath library I always get the wrong results.

For example:

_iq30 d, e;
d = _IQ30(0.5);     //d = 536870912(int) = 0x2000 0000 (hex)
e = _IQ30sin(d);   //result: e = 514779252(int) = 0x1EAEE874(hex); expected: 9370046(int)

Thank you for any help

  • Hi Ka,

    Would you please let us know the version of the library package you use in which the function, _IQsin enclosed??

    Please check through any examples included in the package which uses IQ30sin function.

    When I go through the userguide above, just came across an example given there. Please check the input and results of the values used in the example and compare it with yours.

  • ---- Results for example of IQ29 from page 12 TMS320C64x+ IQmath Library Users Guide: ----
    #include<IQmath.h>
    #define PI 3.14159F
    _iq input, sin_out;
    void main(void )
    {
    input =_IQ29( 0.25*PI ); //result: 421657072(int) = 0x1921F9F0(hex)
    sin_out =_IQ29sin (input ); //result: 379624810(int) = 0x16A09D6A(hex)
    }

    ---- Results for saturation example with IQ30: ----
    #include<IQmath.h>
    #define PI 3.14156
    _iq in1, out1;
    _iq30 in2, out2;
    void main(void )
    {
    in1=_IQ ( 0.25*PI/PI ); /* in1 = 268435456(int) = 0x10000000(hex) */
    out1=_IQsinPU (in1); /* out1=1073741824(int)=0x40000000(hex) */
    in2=_IQ30 (0.25*PI/PI); /* in2 = 268435456(int)=0x10000000(hex)*/
    out2= _IQ30sinPU (in2); /* out2=1073741824(int)=0x40000000(hex) */
    }

    ---- Result for saturation example with IQ29 page 40: ----
    #include<IQmath.h>
    #define PI 3.14156
    _iq in1, out1;
    _iq28 in2, out2;
    void main(void )
    {
    in1=_FtoIQ ( 0.25*PI ); /* in1 = 421657088(int) = 0x1921FA00(hex) */
    out1=_IQsin (in1); /* out1=379624822(int)=0x16A09D76(hex) */
    in2=_FtoIQ29 (0.25*PI/PI); /* in2 = 421657088(int)=0x1921FA00(hex)*/
    out2= _IQ29sin(in2); /* out2=379624822(int)=0x16A09D76(hex) */
    }


    -- Version of used IQmath library: 2.1.4 --
  • Hi Shankari,
    Could I find somewhere another version or library for fixed point sine function for C64x+ processor?

    Regards,
    Ka