DSPRelated.com
Forums

Problem with _IQsin function

Started by ruim...@yahoo.com June 11, 2008
Hello Everybody,

I am a newbie in DSP. I have a project that i am using the TMS320F2812 processor. I need to use _IQsin function therefore i saw in IQmath.pdf, a example with this function. But i can't get the same results of the example.

The example project include this source file (*.c) :

#include
#include "IQmathLib.h"

// Define constants used:

#define PI 3.141592654

//--------
// Main code:
//--------

_iq in1, out1;

void main(void )
{
in1=_IQ(0.25*PI);
out1=_IQsin(_IQ(0.25*PI));
}

Results with the Watch Window :

in1 = 0.7853981853 (Qvalue(29))
out1 = -1.862645149e-09 (Qvalue(29)) WRONG Value!!

I have include this linker file in my project (*.cmd):

/****************************************************************************/
/* Sample Link Command File For, Target Processor(s): F2812 EzDSP
/****************************************************************************/

MEMORY
{
PAGE 0 : RAMH0 (RW) : origin = 0x3f8000, length = 0x002000
BOOTROM (RW) : origin = 0x3ff000, length = 0x000fc0
VECTORS (RW) : origin = 0x3fffc2, length = 0x00003e
RESET (RW) : origin = 0x3fffc0, length = 0x000002

PAGE 1 : RAMM0M1 (RW) : origin = 0x000000, length = 0x000800
RAML0L1 (RW) : origin = 0x008000, length = 0x002000
}

SECTIONS
{
.reset : load = RESET, type = DSECT, PAGE = 0

/* .text needs to be the first section into RAMH0 for */
/* boot to H0 to work properly. */

.text : load = RAMH0, PAGE = 0
.cinit : load = RAMH0, PAGE = 0
.econst : load = RAMH0, PAGE = 0
.bss : load = RAML0L1, PAGE = 1
.ebss : load = RAML0L1, PAGE = 1
.data : load = RAML0L1, PAGE = 1
.const : load = RAML0L1, PAGE = 1
.stack : load = RAMM0M1, PAGE = 1
.sysmem : load = RAML0L1, PAGE = 1

/*==========================================================*/
/* Tables for IQ math functions: */
/*==========================================================*/
/* For K1 device (no tables in boot ROM), use this: */
/*
IQmathTables : load = BOOTROM, PAGE = 0
*/
/* For F2810/12 devices (with tables in Boot ROM) use this: */

IQmathTables : load = BOOTROM, type = NOLOAD, PAGE = 0

/*==========================================================*/
/* IQ math functions: */
/*==========================================================*/
IQmath : load = RAMH0, PAGE = 0
}
I canĀ“t understand what is wrong. I hope you can give me any clue to solve it.

Thanks,

Rui Machado


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Have you defined the global Q value, which has to be set in IQmathLib.h
file. Is your global Q is 29?

On Wed, Jun 11, 2008 at 12:31 PM, wrote:

> Hello Everybody,
>
> I am a newbie in DSP. I have a project that i am using the TMS320F2812
> processor. I need to use _IQsin function therefore i saw in IQmath.pdf, a
> example with this function. But i can't get the same results of the example.
>
> The example project include this source file (*.c) :
>
> #include
> #include "IQmathLib.h"
>
> // Define constants used:
>
> #define PI 3.141592654
>
> //--------
> // Main code:
> //--------
>
> _iq in1, out1;
>
> void main(void )
> {
> in1=_IQ(0.25*PI);
> out1=_IQsin(_IQ(0.25*PI));
> }
> Results with the Watch Window :
>
> in1 = 0.7853981853 (Qvalue(29))
> out1 = -1.862645149e-09 (Qvalue(29)) WRONG Value!!
> I have include this linker file in my project (*.cmd):
> /****************************************************************************/
> /* Sample Link Command File For, Target Processor(s): F2812 EzDSP
>
> /****************************************************************************/
>
> MEMORY
> {
> PAGE 0 : RAMH0 (RW) : origin = 0x3f8000, length = 0x002000
> BOOTROM (RW) : origin = 0x3ff000, length = 0x000fc0
> VECTORS (RW) : origin = 0x3fffc2, length = 0x00003e
> RESET (RW) : origin = 0x3fffc0, length = 0x000002
>
> PAGE 1 : RAMM0M1 (RW) : origin = 0x000000, length = 0x000800
> RAML0L1 (RW) : origin = 0x008000, length = 0x002000
> }
>
> SECTIONS
> {
> .reset : load = RESET, type = DSECT, PAGE = 0
>
> /* .text needs to be the first section into RAMH0 for */
> /* boot to H0 to work properly. */
>
> .text : load = RAMH0, PAGE = 0
> .cinit : load = RAMH0, PAGE = 0
> .econst : load = RAMH0, PAGE = 0
> .bss : load = RAML0L1, PAGE = 1
> .ebss : load = RAML0L1, PAGE = 1
> .data : load = RAML0L1, PAGE = 1
> .const : load = RAML0L1, PAGE = 1
> .stack : load = RAMM0M1, PAGE = 1
> .sysmem : load = RAML0L1, PAGE = 1
>
> /*

OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x
Hi naayagi, the global Q is 29 and it is defined in IQmathlib.h file.

Also I tried the Tuan's suggestion, in below, but the results kept the same values :(

void main(void )
{
in1=_IQ(0.25*PI);
out1=_IQsin( _IQmpy( _IQ(0.25), _IQ(PI) ) );
}

Regards,
Rui Machado


OMAP35x EVM jump-starts low-power apps
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building applications based on the OMAP35x architecture: http://www.DSPRelated.com/omap35x