原创 IOMath库的使用

2008-9-8 01:52 2264 4 4 分类: 处理器与DSP

1. Include the IQmathLib.h include file<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


 


2. Link your code with the IQmath object code library, IQmath.lib.


 


3. Use a correct linker command file to place “IQmath” section in program memory


 


4. The section “IQmathTables” contains look-up tables for IQmath functions and it is


available in the BOOTROM of F2810/F2812 devices. Hence, this section must be of set


to “NOLOAD” type in the linker command. This facilitates referencing look-up table


symbols, without actually loading the section into the target.


Note:


IQmath functions are assembled in ”IQmath” section & the look -up tables used to


perform high precision computation are placed in “IQmathTables” section.


 


IQmath Linker Command File (F28x device):


MEMORY


{


PAGE 0:


BOOTROM (RW) : origin = 0x3ff000, length = 0x000fc0


RAMH0 (RW) : origin = 0x3f8000, length = 0x002000


}


SECTIONS


{


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


IQmath : load = RAMH0, PAGE = 0


}


 


 


For example, the following code contains a call to the IQ25sin routines in IQmath Library:


 


#include<IQmathLib.h> /* Header file for IQmath routine */


#define PI 3.14159


_iq input, sin_out;


void main(void )


{


input=_IQ29(0.25*PI); /* p 25 . 0 radians represented in Q29 format */


sin_out =_IQ29sin(input);


}


 


 


5.  Selecting GLOBAL_Q format


CASE I:


Default GLOBAL_Q format is set to Q24. Edit “IQmathLib.h” header file to modify this


value as required, user can choose from Q1 to Q29 as GLOBAL_Q format. Note that


modifying this value means that all the GLOBAL_Q functions will use this Q format for


input/output, unless this symbolic definition is overridden in the source code.


 


#ifndef GLOBAL_Q


#define GLOBAL_Q 24 /* Q1 to Q29 */


#endif


 


 


CASE II :


A complete system consists of various modules. Some modules may require different


precision, then the rest of the system. In such situation, we need to over-ride the


GLOBAL_Q defined in the “IQmathLib.h” file and use the local Q format.


This can be easily done by defining the GLOBAL_Q constant in the source file of the


module before the include statement.


 


#define GLOBAL_Q 27 /* Set the Local Q value */


#include <IQmathLib.h>

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
4
关闭 站长推荐上一条 /3 下一条