STM32F405/07xx and STM32F415/417xx microcontrollers
Introduction
This application note explains how to use floating-point units (FPU) with STM32F405/07xx
and STM32F415/417xx microcontrollers and provides a short overview of:
■ Floating-point arithmetic
■ STM32F405/07xx and STM32F415/417xx family floating-point unit
An application example is given at the end of this application note.
Ta bl e 1 lists the microcontrollers and development tools concerned by this application note.
Table 1.Applicable products and tools
TypeApplicable products
Microcontrollers
Development toolsSTM3240G-EVAL evaluation board
STM32F405/07xx and STM32F415/417xx high-performance MCUs with
DSP and FPU instructions
Floating-point numbers are used to represent non-integer numbers. They are composed of
3 fields:
●the sign
●the exponent
●the mantissa
Such a representation allows a very wide range of number coding, making floating-point
numbers the best way to deal with real numbers. Floating-point calculations can be
accelerated using a Floating-point unit (FPU) integrated in the processor.
1.1 Fixed-point or floating-point
One alternative to floating-point is fixed-point, where the exponent field is fixed. But if fixedpoint is giving better calculation speed on FPUless processors, the range of numbers and
their dynamic is low. As a consequence, a developer using the fixed-point technique will
have to check carefully any scaling/saturation issues in its algorithm.
Table 2.Integer numbers dynamic
CodingDynamic
Int848 dB
Int1696 dB
Int32192 dB
Int64385 dB
The C language offers the float and the double types for floating-point operations. At a
higher level, modelization tools, such as matlab or scilab, are generating C code mainly
using float or double. No floating-point support means modifying the generated code to
adapt it to fixed-point. And all the fixed-point operations have to be handcoded by the
programmer.
Table 3.Floating-point numbers dynamic
CodingDynamic
half precision180 dB
single precision1529 dB
double precision12318 dB
When used natively in code,floating-point operations will decrease the development time of
a project. It is the most efficient way to implement any mathematical algorithm.
Doc ID 022737 Rev 15/21
Floating-point arithmeticAN4044
1.2 Floating-point unit (FPU)
Floating-point calculations require a lot of resources, as for any operation between two
numbers. For example, we need to:
●align the two numbers (have them with the same exponent)
●perform the operation
●round out the result
●code the result
On an FPUless processor, all these operations are done by software through the C compiler
library and are not visible to the programmer; but the performances are very low.
On a processor having an FPU, all of the operations are entirely done by hardware in a
single cycle, for most of the instructions. The C compiler does not use its own floating-point
library but directly generates FPU native instructions.
When implementing a mathematical algorithm on a microprocessor having an FPU, the
programmer does not have to choose between performance and development time. The
FPU brings reliability allowing to use directly any generated code through a high level tool,
such as matlab or scilab, with the highest level of performance.
6/21Doc ID 022737 Rev 1
AN4044IEEE standard for floating-point arithmetic (IEEE 754)
2 IEEE standard for floating-point arithmetic (IEEE 754)
The usage of the floating-point arithmetic has always been a need in computer science
since the early ages. At the end of the 30’s, when Konrad Zuse developed his Z series in
Germany, floating-points were already in. But the complexity of implementing a hardware
support for the floating-point arithmetic has discarded its usage for decades.
In the mid 50’s, IBM, with its 704, introduced the FPU in mainframes; and in the 70’s, various
platforms were supporting floating-point operations but with their own coding techniques.
The unification took place in 1985 when the IEEE published the standard 754 to define a
common approach for floating-point arithmetic support.
2.1 Overview
The various types of floating-point implementations over the years led the IEEE to
standardize the following elements:
●number formats
●arithmetic operations
●number conversions
●special values coding
●4 rounding modes
●5 exceptions and their handling
2.2 Number formats
All values are composed of three fields:
●Sign: s
●Biased exponent:
–sum of the exponent = e
–constant value = bias
●Fraction (or mantissa): f
The values can be coded on various lengths:
●16-bit: half precision format
●32-bit: single precision format
●64-bit: double precision format
Doc ID 022737 Rev 17/21
Loading...
+ 14 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.