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.

}<br />

// output should be 0x5A820000 ~ FRAC32(0.70710678)<br />

f32Out = GFLIB_Sqrt (f32In);<br />

4.83 Function GFLIB_Sqrt_F16<br />

This function returns the square root of input value.<br />

4.83.1 Declaration<br />

tFrac16 GFLIB_Sqrt_F16(tFrac16 f16In);<br />

4.83.2 Arguments<br />

Table 4-105. GFLIB_Sqrt_F16 arguments<br />

Type Name Direction Description<br />

tFrac16 f16In input The input value.<br />

4.83.3 Return<br />

The function returns the square root of the input value. The return value is within the [0,<br />

1) fraction range.<br />

4.83.4 Description<br />

The GFLIB_Sqrt_F16 function computes the square root of the input value.<br />

Chapter 4 API References<br />

The computations are made by a simple iterative testing of each bit starting from the most<br />

significant one. In total, 15 iterations are made, each per<strong>for</strong>ming the following steps:<br />

1. Add to the tentative square root value a single testing bit.<br />

2. Square the tentative square root value <strong>and</strong> test whether it is greater or lower than the<br />

input value.<br />

3. If greater, then clear the bit in the tentative square root value.<br />

4. Shift the single testing bit right<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 />

Freescale Semiconductor, Inc. 415

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

Saved successfully!

Ooh no, something went wrong!