03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Function GFLIB_Lut1D_FLT<br />

Note<br />

The function per<strong>for</strong>ms a linear interpolation.<br />

CAUTION<br />

The function does not check whether the input abscissa value is<br />

within the range allowed by the interpolating data table<br />

pParam->pf16Table. If the computed interval index points to<br />

data outside the provided data table, then the interpolation will<br />

be computed with invalid data.<br />

4.68.5 Re-entrancy<br />

The function is re-entrant.<br />

4.68.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16In;<br />

tFrac16 f16Out;<br />

GFLIB_LUT1D_T_F16 trf16MyLut1D = GFLIB_LUT1D_DEFAULT_F16;<br />

tFrac16 pf16Table1D[9] = {FRAC16 (-1),FRAC16 (0),FRAC16 (-0.2),FRAC16<br />

(0),FRAC16 (0.2),<br />

FRAC16 (0),FRAC16 (0.8),FRAC16 (1),FRAC16 (1)};<br />

void main(void)<br />

{<br />

// setting parameters <strong>for</strong> Lut1D function<br />

trf16MyLut1D.pf16Table = &(pf16Table1D[4]);<br />

trf16MyLut1D.s16ShamOffset = 2;<br />

trf16MyLut1D.s16ShamIntvl = 15 - 2;<br />

// input vector = 0.5<br />

f16In = FRAC16 (0.5);<br />

}<br />

// output should be 0x6666 ~ FRAC16(0.8)<br />

f16Out = GFLIB_Lut1D_F16 (f16In,&trf16MyLut1D);<br />

// output should be 0x6666 ~ FRAC16(0.8)<br />

f16Out = GFLIB_Lut1D (f16In,&trf16MyLut1D,Define F16);<br />

// ##############################################################<br />

// Available only if 16-bit fractional implementation selected<br />

// as default<br />

// ##############################################################<br />

// output should be 0x6666 ~ FRAC16(0.8)<br />

f16Out = GFLIB_Lut1D (f16In,&trf16MyLut1D);<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

364 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!