当前位置:网站首页>Start with stm32f4 floating point operation (FPU) function + use DSP Library
Start with stm32f4 floating point operation (FPU) function + use DSP Library
2022-04-22 07:08:00 【Your youth my dream】
The parameters involved : Here we use stm32F4 MDK5.2 For example
(1) Configuration on FPU Functional logo
#define __FPU_PRESENT 1U // stay stm32f4xx.h The system has been configured
#define __FPU_USED 1U // This is in core_cm4.h in , Need configuration

As you can see from the picture , want First Judge __CC_ARM Whether to define , Again Judge __TARGET_FPU_VFP Whether to define , Last Judge __FPU_PRESENT Has been configured to 1, front 3 When both conditions are true , only To configure __FPU_USED=1; It can be simplified , Configure... Directly in the user program __FPU_USED=1 that will do ;
__CC_ARM: #define __CC_ARM //1 Some systems will configure themselves
__TARGET_FPU_VFP: The defined equipment has FPU function , So add the next sentence :
#define __TARGET_FPU_VFP //1
Of course __CC_ARM、__TARGET_FPU_VFP It can also be in MDK->Option->C/C++->… In the definition of , Here's the picture

(2) Floating point configuration function at void SystemInit(void) That is to say system_stm32f4xx.c in
void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
That's it In fact, it can not be configured __FPU_PRESENT and __FPU_PRESENT, Directly compile the condition to delete , This procedure works ; If some libraries do not have these configurations , Then the user can add
…………………..
}
(3) Add header file
#include “arm_math.h” Use STM32 Its own mathematical processing function , Simultaneous addition arm_math.h Header file path , At this time, the compiler will report an error , Tips :#error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0", It means that there is no definition of kernel mathematical type , solve ,2 A way :
Method 1: stay MDK Configure... In the software , I'm using M4, choice ARM_MATH_CM4

Method 2: The user can define ARM_MATH_CM4 that will do

2 There are two ways to see which users like
(4)MDK The configuration is as follows , Select... From the floating point options :Use Single Precision
If you choose Not Used Error will be reported at compile time

The above configuration is already available STM32 Floating point operations for FPU The function of , test result , use 2 Multiply decimals , Online simulation , Look at what appears in disassembly xxx.F32 sentence , It means that FPU function

Others will be in MDK To configure C++ define Medium plus ARM_MATH_MATRIX_CHECK,ARM_MATH_ROUNDING These two configurations
ARM_MATH_ROUNDING It's the rounding function , Can not add ;
ARM_MATH_MATRIX_CHECK Is the matrix parameter check function , Can not add
(5) If you use STM32 Self contained dsp The operation function also needs to add the corresponding library function
The above is just open STM32 Internal hardware FPU Floating point operation function , There is no mention of DSP
Want to use DSP There's still some work to be done
- Join in dsp Math library ( You can add it to any folder )

arm_cortexM4lf_math.lib What is the function ?
This is the following specific dsp An assembly of functions or a library compiled from them , The following specific functions are c Compiling , If you make your employees do this directly , It will lead to low efficiency , So use the corresponding assembly function to realize , Don't pay attention to this lib file , If you want to know the specific function , You can refer to the following instructions , Look at specific .C File to find the corresponding function
arm_cortexM4lf_math.lib Already included all dsp Specific function , In fact, just add this , This .lib The file cannot be opened ; It is not necessary to add the following corresponding .C file , Provided here .C Files just let designers know how to call functions , And internal program implementation steps
But not vice versa , If you add the corresponding c file , Instead of joining lib The file will compile and report an error
2. The specific functions of the official tape dsp function library ( This does not have to be added , It's just that the designer knows , Know the function name )

3. Usage method
For example, use sine sin To join arm_sin_f32.c( No need )
cosine cos To join arm_cos_f32.c call ( No need )
There is no corresponding header file , To add other header files , You can see the specific c file



Open the corresponding library .c file , There is a function name , When actually using it, just press this , You can't do as before math.h The corresponding function name in
CosVal=arm_cos_f32(radians);// Calculate the cosine function
You can only join arm_cortexM4lf_math.lib file , Then, the function of the corresponding function c File removal project , Continue to call the corresponding dsp function , Same operation
exception handling :
Sometimes configuration FPU Incorrect , There will be HardFault_Handler, as a result of : The compiler generates floating-point instructions , But the hardware does not turn on the floating-point operation function , Such an operation is wrong , Check whether the configuration is correct
版权声明
本文为[Your youth my dream]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220603472497.html
边栏推荐
- STM32 learning record 0001 - learning preparation
- STM32 learning record 0003 -- Interpretation of STM32 chip
- 从 Spec.到芯片_(数字IC、模拟IC、FPGA/CPLD设计的流程及EDA工具)
- STM32 learning record 0005 - JLINK download and debugging
- Typec转HDMI 4K30HZ扩展芯片方案CS5261和CS5266设计参数及电路对比
- The capacitor on PCBA is cracked and short circuited. Why is it the fault of design?
- FreeRTOS v10.1.0源码中文注释版
- Qinheng ch573 development board
- 替代RTD2171U|CS5266设计电路|TYPEC转HDMI方案|CS5266AN
- 消防设备光纤联网CAN转光纤转换器
猜你喜欢

数字IC设计自学入门难吗?如何快速入门呢?

C技能树测评——0415体验日记

Design parameters and circuit comparison of type C to HDMI 4k30hz expansion chip scheme cs5261 and cs5266

I didn't dare to think about it before

6.ROS是什么

MATLAB:去除音频信号噪音

数字IC设计和CS选那个?
![[Blue Bridge Cup review] straight line](/img/93/28215467fd61e7b7fb3798b86b1271.png)
[Blue Bridge Cup review] straight line

谱瑞PS8625替代方案|PS8622替代方案|高性价比EDP转LVDS转接板方案CS5211设计开发

CS5202芯片规格书|CS5202替代CS5212|HDMI转VGA芯片
随机推荐
pyautocad 选择对象报错的解决方案
CAN总线记录诊断助手
[蓝桥杯省赛] 负载均衡
6. What is ROS
LwIP 1.4.1 Chinese annotation source code
替代 FE1.1s HUB读卡主控芯片-MA8601
C skill tree evaluation - 0415 experience diary
STM32 learning record - development environment installation
沁恒CH573开发板上手
Remplacer Fe1. 1S hub READER CARD Master Control Chip - ma8601
[mcukeys] a general, flexible, configurable and portable implementation of key event processing
fastmock使用说明
Stm32wb55 RTT based ble sample making process
如何成为IC验证工程师?
Lcfnet series can to optical fiber Ethernet equipment realizes ultra long-distance optical fiber communication between can networks
Solution of overdetermined equation
HDMI2. Design circuit comparison between asw3642 and ts3dv642
CS5213新版规格书|CS5213新版说明书|HDMI转VGA带音频信号输出方案设计
How many ground vias are needed next to the depth interpretation signal hole
LwIP 1.4.1中文注释源码