07.03.2014 Views

IQmath Library

IQmath Library

IQmath Library

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

IQNmpyI32int<br />

Integer portion of (IQN*LONG)<br />

Description<br />

Declaration<br />

This function multiplies an IQ number with a long integer and returns the<br />

integer part of the result.<br />

Global IQ function (IQ format = GLOBAL_Q)<br />

long _IQmpyI32int(_iq A, long B)<br />

Q format specific IQ function (IQ format = IQ1 to IQ30)<br />

long _IQNmpyI32int( _iqN A, long B)<br />

Input Format<br />

Global IQ function (IQ format = GLOBAL_Q)<br />

Operand “A” is an IQ number in GLOBAL_Q format and “B” is the long<br />

integer.<br />

Q format specific IQ function (IQ format = IQ1 to IQ30)<br />

Operand “A” is an IQ number in IQN format and “B” is the long integer.<br />

Output Format<br />

Global IQ function (IQ format = GLOBAL_Q)<br />

Integer part of the result (32-bit)<br />

Q format specific IQ function (IQ format = IQ1 to IQ30)<br />

Integer part of the result (32-bit)<br />

Usage<br />

Example 1:<br />

Convert an IQ value in the range [- 1.0, +1.0] to a DAC value with the<br />

range [ 0 to 1023]:<br />

_iq Output;<br />

long temp;<br />

short OutputDAC;<br />

temp = _IQmpyI32int(Output, 512); // value converted to +/- 512<br />

temp += 512; // value scaled to 0 to 1023<br />

if( temp > 1023 )<br />

temp = 1023;<br />

// saturate within range of DAC<br />

if( temp < 0 )<br />

temp = 0;<br />

OutputDAC = (int )temp;<br />

// output to DAC value<br />

Note: The integer operation performs the multiply and calculates the<br />

integer portion from the resulting 64-bit calculation. Hence it avoids any<br />

overflow conditions.<br />

©Texas Instruments Inc., June 2002 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!