STM32F429之使用FPU和DSPCMSIS的DSP库提供了一类高级数学处理功能,包括:
- Basic math functions
- Fast math functions
- Complex math functions
- Filters
- Matrix functions
- Transforms
- Motor control functions
- Statistical functions
- Support functions
- Interpolation functions
该库使用不同的函数来处理8位、16位和32位整型以及32位浮点型数据。STM32F429具有浮点处理器(FPU),在开启FPU的情况下,浮点数运算性能大大提高,配以DSP库的支持,性能尤其出 {MOD}。本文介绍如何在IAR建立的工程中开启FPU并使用DSP库。欲使用DSP库,需要包含
"arm_math.h"文件,该文件在"CMSISinclude"目录下。#include "arm_math.h"接下来IAR在编译连接程序时,将会寻找对应的连接库,连接库在"CMSISLibARM"路径下,CMSIS对不同连接库的说明如下:
- arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
- arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
- arm_cortexM4l_math.lib (Little endian on Cortex-M4)
- arm_cortexM4b_math.lib (Big endian on Cortex-M4)
- arm_cortexM3l_math.lib (Little endian on Cortex-M3)
- arm_cortexM3b_math.lib (Big endian on Cortex-M3)
- arm_cortexM0l_math.lib (Little endian on Cortex-M0)
- arm_cortexM0b_math.lib (Big endian on Cortex-M3)
由于STM32F429属于小端模式,因此连接到"
arm_cortexM4lf_math.lib"文件上。另外,在"C/C++ Compiler"项的"Preprocessor"选项卡下添加如下预定义符号- ARM_MATH_CM4
- ARM_MATH_MATRIX_CHECK
- ARM_MATH_ROUNDING
- __FPU_PRESENT
- __FPU_USED
如果没有"
ARM_MATH_CM4"符号,在编译时将会提示找不到"armcm4.h"文件。这是由于文件中有如下内容: #if defined
(ARM_MATH_CM4)
#include "core_cm4.h" #elif defined
(ARM_MATH_CM3)
#include "core_cm3.h" #elif defined
(ARM_MATH_CM0)
#include "core_cm0.h" #define ARM_MATH_CM0_FAMILY
#elif defined
(ARM_MATH_CM0PLUS)
#include "core_cm0plus.h" #define ARM_MATH_CM0_FAMILY
#else #include "ARMCM4.h" #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on
ARM_MATH_CM4....."
#endif如果没有"ARM_MATH_MATRIX_CHECK"、"ARM_MATH_ROUNDING"、"__FPU_PRESENT"和"__FPU_USED"符号将会在连接时提示如下错误:
no definition for "__iar_program_start"
no definition for "__iar_data_init3"