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 MLIB_Convert_F32F16<br />

4.124.8 Code Example<br />

#include "mlib.h"<br />

tFrac16 f16In1, f16In2;<br />

tFrac16 f16Out;<br />

void main(void)<br />

{<br />

// input value 1 = 0.25<br />

f16In1 = FRAC16 (0.25);<br />

// input value 2 = 0.25<br />

f16In2 = FRAC16 (0.25);<br />

}<br />

// output should be FRAC16(0.5) = 0x4000<br />

f16Out = MLIB_AddSat_F16(f16In1, f16In2);<br />

// output should be FRAC16(0.5) = 0x4000<br />

f16Out = MLIB_AddSat (f16In1, f16In2, Define F16);<br />

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

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

// as default<br />

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

// output should be FRAC16(0.5) = 0x4000<br />

f16Out = MLIB_AddSat (f16In1, f16In2);<br />

4.125 Function MLIB_Convert_F32F16<br />

This function converts the input value to different representation with scale.<br />

4.125.1 Declaration<br />

tFrac32 MLIB_Convert_F32F16(register tFrac16 f16In1, register tFrac16 f16In2);<br />

4.125.2 Arguments<br />

Table 4-162. MLIB_Convert_F32F16 arguments<br />

Type Name Direction Description<br />

register tFrac16 f16In1 input Input value in 16-bit fractional <strong>for</strong>mat to be converted.<br />

register tFrac16 f16In2 input Scale factor in 16-bit fractional <strong>for</strong>mat.<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 />

566 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!