qfplib次用汇编实现,是一种用来在ARM 单片机上运行的软件浮点库,适用于ARM Cortex- M0/M0+/M1/M23/M3/M4/M7/M33/M55等ARM MCU,特别是适用于M0/M0+,因为这些和是不具备硬件浮点运算的,本期测评主要是在STM32F769I-DISCO上测试。 1。首先下载qfplib https://www.quinapalus.com/qfplib.html 我们点击M3 进行下载 复制到工程文件夹 2。打开我们之前建立好的串口工程,串口打印这里不在赘述。 添加这两个,上面是用来测量算法时间,下面是qfplib 同时添加文件 3。main文件中进行修改 添加头文件 include "main.h"/ Private includes ----------------------------------------------------------/ / USER CODE BEGIN Includes / include "stdio.h"include "code_time_measurement.h"include "qfplib-m3.h"include "math.h"4。先进性qfplib浮点库性能测试,修改代码如下 printf("======================qfplib==========================\r\n"); CODE_TIME_START("qfplib浮点运算"); printf("qfp_fsqrt = %f\r\n", qfp_fsqrt(3.4f)); CODE_TIME_EVENT("qfp_fsqrt(3.4f)"); printf("qfp_fexp = %f\r\n", qfp_fexp(4.124f)); CODE_TIME_EVENT("qfp_fexp(4.124f)"); printf("qfp_fln = %f\r\n", qfp_fln(88.124f)); CODE_TIME_EVENT("qfp_fln(88.124f)"); printf("qfp_fsin = %f\r\n", qfp_fsin(3.1415926f/4)); CODE_TIME_EVENT("qfp_fsin(3.1415926f/4)"); printf("qfp_fcos = %f\r\n", qfp_fcos(3.1415926f/4)); CODE_TIME_EVENT("qfp_fcos(3.1415926f/4)"); printf("qfp_ftan = %f\r\n", qfp_ftan(3.1415926f/4)); CODE_TIME_EVENT("qfp_ftan(3.1415926f/4)"); printf("qfp_fatan2 = %f\r\n", qfp_fatan2(1.0f, 2.0f)); CODE_TIME_EVENT("qfp_fatan2(1.0f, 2.0f)"); CODE_TIME_STOP(); 一定要关闭硬件浮点运算,操作如上图 串口打印如下图 5。进行硬件浮点运算,修改代码如下 printf("======================hardfpu==========================\r\n"); CODE_TIME_START("硬件浮点运算"); printf("sqrtf = %f\r\n", sqrtf(3.4f)); CODE_TIME_EVENT("sqrtf(3.4f)"); printf("expf = %f\r\n", expf(4.124f)); CODE_TIME_EVENT("expf(4.124f)"); printf("logf = %f\r\n", logf(88.124f)); CODE_TIME_EVENT("logf(88.124f)"); printf("sinf = %f\r\n", sinf(3.1415926f/4)); CODE_TIME_EVENT("sinf(3.1415926f/4)"); printf("cosf = %f\r\n", cosf(3.1415926f/4)); CODE_TIME_EVENT("cosf(3.1415926f/4)"); printf("tanf = %f\r\n", tanf(3.1415926f/4)); CODE_TIME_EVENT("tanf(3.1415926f/4)"); printf("atan2f = %f\r\n", atan2f(1.0f, 2.0f)); CODE_TIME_EVENT("atan2f(1.0f, 2.0f)"); CODE_TIME_STOP(); 同时使能硬件浮点运算 串口打印输出 6。两者进行对比 发现qfplib的浮点运行性能和硬件浮点运算性能相差无几,几乎达到了硬件浮点性能,这使得在M0/M0+/M1/M2等不具备硬件浮点运算的ARM内核可以运行浮点运算,非常完美的库!!!! 大家可以下载移植测试!!!!!!!!!!!!!!!!! |
OpenBLT移植到STM32F103战舰开发板上适用于所有STM32F103系列的Bootloader
MultiButton移植到STM32F103战舰开发板
coremark移植到STM32F769I-DISCO开发板的两种方法
【GUI板免费申请活动】【圣诞GUI】使用F746-DISO基于TouchGFX的圣诞树
【圣诞专享活动】使用TouchGFX做GUI显示:圣诞快乐&Merry Christmas!
STM32F103移植LittlevGUI代码
【STM32MP157】从ST官方例程中分析RPMsg-TTY/SDB核间通信的使用方法
刘氓兔的杂谈【001】-片上USB 高速PHY
FreeRTOS学习笔记2
【STM32H7S78-DK评测】-5 LVGL&DMA2D DEMO测试