当前位置:网站首页>【嵌入式】Cortex M4F DSP库
【嵌入式】Cortex M4F DSP库
2022-07-06 08:40:00 【好奇宝宝·权】
使用CM4内核自带的FPU需要在编译的时候添加编译选项:--cpu Cortex-M4.fp,以使能FPU指令集,否则使用的是普通Thumb2指令实现的DSP函数。同时还需添加宏定义:ARM_MATH_CM4,这在CMSIS DSP Library的arm_math.h里面用到。CMSIS DSP Library可以在ARM的官网找到:https://developer.arm.com/tools-and-software/embedded/cmsishttps://developer.arm.com/tools-and-software/embedded/cmsis
如果使用MDK的话,直接在Runtime Environment管理器里面添加DSP库,Floating Point Hardware选择Single Precision,预定义宏加上ARM_MATH_CM4,这样工程自动添加了DSP库:
上面那个库是使用FPU指令集生成的DSP库,下面的是没有使用FPU指令集......
DSP库测试:
static float sin_out[256];
static float fft_mag[256];
static float fft_out[256];
static void DSP_Test()
{
#define FFT_LENGTH 256
arm_rfft_fast_instance_f32 S;
// 创建一个t=2S钟之内的采样数据,采样点数FFT_LENGTH,采样周期T=t/FFT_LENGTH,采样频率F=1/T
for(uint16_t i = 0; i < FFT_LENGTH; i++)
{
sin_out[i] = arm_sin_f32(i*2*3.1416f/128) + 0.3f*arm_sin_f32(i*2*3.1416f/16); //
}
for(uint16_t i = 0; i < FFT_LENGTH; i++)
{
LOGI("%.4f\r\n",sin_out[i]);
DDL_DelayUS(1000);
}
arm_rfft_fast_init_f32(&S, FFT_LENGTH); //初始化1024点FFT参数
arm_rfft_fast_f32(&S,sin_out,fft_out,0); //计算FFT
arm_cmplx_mag_f32(fft_out,fft_mag, FFT_LENGTH); //计算模值
for(uint16_t i = 0; i < FFT_LENGTH / 2; i++)
{
LOGI("%4d %4.4f %4.4f\r\n", i, (float)i * 128 / FFT_LENGTH, fft_mag[i]);//frequency = N * sample frequency / FFT length
DDL_DelayUS(1000);
}
}
结果在Excel上画图,采样点图像(1Hz正弦波和8Hz正弦波叠加):
FFT计算结果:
两个波峰分别对应1Hz和8Hz,和采样点的频率一致。
边栏推荐
- 企微服务商平台收费接口对接教程
- How to conduct interface test? What are the precautions? Nanny level interpretation
- [NVIDIA development board] FAQ (updated from time to time)
- PLT in Matplotlib tight_ layout()
- 如何进行接口测试测?有哪些注意事项?保姆级解读
- 【Nvidia开发板】常见问题集 (不定时更新)
- Rviz仿真时遇到机器人瞬间回到世界坐标原点的问题及可能原因
- Tcp/ip protocol
- hutool优雅解析URL链接并获取参数
- What is CSRF (Cross Site Request Forgery)?
猜你喜欢
Marathon envs project environment configuration (strengthen learning and imitate reference actions)
Unified ordering background interface product description Chinese garbled
【MySQL】日志
Light of domestic games destroyed by cracking
Mobile phones and computers on the same LAN access each other, IIS settings
ROS编译 调用第三方动态库(xxx.so)
MySQL learning records 12jdbc operation transactions
Problems in loading and saving pytorch trained models
egg. JS project deployment online server
【刷题】牛客网面试必刷TOP101
随机推荐
Image,cv2读取图片的numpy数组的转换和尺寸resize变化
广州推进儿童友好城市建设,将探索学校周边200米设安全区域
Research and investment forecast report of citronellol industry in China (2022 Edition)
pytorch训练好的模型在加载和保存过程中的问题
Analysis of the source code of cocos2d-x for mobile game security (mobile game reverse and protection)
Image, CV2 read the conversion and size resize change of numpy array of pictures
Function coritization
Bottom up - physical layer
如何进行接口测试测?有哪些注意事项?保姆级解读
2022.02.13 - NC002. sort
Golang force buckle leetcode 1020 Number of enclaves
Report on Market Research and investment prospects of China's silver powder industry (2022 Edition)
The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
JVM performance tuning and practical basic theory - Part 1
TCP/IP协议
软件卸载时遇到trying to use is on a network resource that is unavailable
Deep analysis of C language pointer
Purpose of computer F1-F12
Shift Operators
Roguelike game into crack the hardest hit areas, how to break the bureau?