In addition to installing the IQmath software, to include a IQmath function in your code you have to:
*Include the IQmathLib.h include file
*Link your code with the IQmath object code library,IQmath.lib.
*Use a correct linker command file to place "IQmath" section in program memory.
*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.
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; //typedef long _iq; /* Fixed point data type: //GLOBAL_Q format
void main(void)
{
input=_IQ30(0.25*PI); /* 0.25*PI radians represented in Q30 format */
sin_out =_IQ30sin(input);
}
IQmath Function Naming Convention
*GLOBAL_Q function, that takes input/output in GLOBAL_Q format
Examples:
· _IQsin(A) /* High Precision SIN */
· _IQcos(A) /* High Precision COS */
· _IQrmpy(A,B) /* IQ multiply with rounding */
//*****************************************************************//
CASE1
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.
#ifndef GLOBAL_Q
#define GLOBAL_Q 24 /* Q1 to Q29 */
#endif
CASE2
#define GLOBAL_Q 27 /* Set the Local Q value */
#include <IQmathLib.h>
//*****************************************************************//
|