IQmath Library
IQmath Library
IQmath Library
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3.3. Calling a <strong>IQmath</strong> Function from C<br />
In addition to installing the <strong>IQmath</strong> software, to include a <strong>IQmath</strong> function in your code you<br />
have to:<br />
q<br />
q<br />
q<br />
q<br />
Include the <strong>IQmath</strong>Lib.h include file<br />
Link your code with the <strong>IQmath</strong> object code library, <strong>IQmath</strong>.lib.<br />
Use a correct linker command file to place “<strong>IQmath</strong>” section in program memory<br />
The section “<strong>IQmath</strong>Tables” contains look-up tables for <strong>IQmath</strong> functions and it is<br />
available in the BOOTROM of F2810/F2812 devices. Hence, this section must be of set<br />
to “NOLOAD” type in the linker command. This facilitates referencing look-up table<br />
symbols, without actually loading the section into the target.<br />
Note:<br />
<strong>IQmath</strong> functions are assembled in ”<strong>IQmath</strong>” section & the look -up tables used to<br />
perform high precision computation are placed in “<strong>IQmath</strong>Tables” section.<br />
<strong>IQmath</strong> Linker Command File (F28x device)<br />
MEMORY<br />
{<br />
PAGE 0:<br />
BOOTROM (RW) : origin = 0x3ff000, length = 0x000fc0<br />
RAMH0 (RW) : origin = 0x3f8000, length = 0x002000<br />
}<br />
SECTIONS<br />
{<br />
<strong>IQmath</strong>Tables : load = BOOTROM, type = NOLOAD, PAGE = 0<br />
<strong>IQmath</strong> : load = RAMH0, PAGE = 0<br />
}<br />
For example, the following code contains a call to the IQ25sin routines in <strong>IQmath</strong> <strong>Library</strong>:<br />
#include /* Header file for <strong>IQmath</strong> routine */<br />
#define PI 3.14159<br />
_iq input, sin_out;<br />
void main(void )<br />
{<br />
input=_IQ29(0.25*PI); /* 0.25×<br />
π radians represented in Q29 format */<br />
sin_out =_IQ29sin(input);<br />
}<br />
©Texas Instruments Inc., June 2002 5