使用STM32F405_407xx和STM32F415_417xx的FPU模块
- 格式:pdf
- 大小:282.63 KB
- 文档页数:21
March 2012Doc ID 022737 Rev 11/21
AN4044
Application note
Using floating-point unit (FPU) with
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.
Table 1 lists the microcontrollers and development tools concerned by this application note.
Table 1.
Applicable products and tools
Type
Applicable products
Microcontrollers STM32F405/07xx and STM32F415/417xx high-performance MCUs with DSP and FPU instructions Development tools
STM3240G-EVAL evaluation board
Contents AN4044
Contents
1Floating-point arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1Fixed-point or floating-point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2Floating-point unit (FPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2IEEE standard for floating-point arithmetic (IEEE754) . . . . . . . . . . . . . 7
2.1Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2Number formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1Normalized numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.2Denormalized numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.3Zeros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.4Infinites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.5NaN (Not-a-Number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.6Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3Rounding modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4Arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5Number conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6Exception and exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3STM32F4 floating-point unit (FPU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1Special operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2Floating-point status and control register (FPSCR) . . . . . . . . . . . . . . . . . 12
3.2.1Code condition bits: N, Z, C, V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.2Mode bits: AHP, DN, FZ, RM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.3Exception flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3Exception management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4Programmers model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5FPU instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5.1FPU arithmetic instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5.2FPU compare & convert instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5.3FPU load/store instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4Application example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2/21Doc ID 022737 Rev 1