当前位置:网站首页>【嵌入式】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/cmsis
https://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,和采样点的频率一致。
边栏推荐
- 2022.02.13 - 238. Maximum number of "balloons"
- Restful API design specification
- LDAP應用篇(4)Jenkins接入
- 【Nvidia开发板】常见问题集 (不定时更新)
- VMware 虚拟化集群
- JS native implementation shuttle box
- [cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
- egg. JS project deployment online server
- ROS compilation calls the third-party dynamic library (xxx.so)
- 704 binary search
猜你喜欢

sublime text的编写程序时的Tab和空格缩进问题
![[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes](/img/ac/773ce8ee7f380df19edf8373250608.jpg)
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes

TCP/IP协议

Sublime text using ctrl+b to run another program without closing other runs

Computer cleaning, deleted system files

Synchronized solves problems caused by sharing

目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台

marathon-envs项目环境配置(强化学习模仿参考动作)

MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object

企微服务商平台收费接口对接教程
随机推荐
ROS compilation calls the third-party dynamic library (xxx.so)
Roguelike game into crack the hardest hit areas, how to break the bureau?
Delay initialization and sealing classes
MySQL learning record 11jdbcstatement object, SQL injection problem and Preparedstatement object
Research and investment forecast report of citronellol industry in China (2022 Edition)
Process of obtaining the electronic version of academic qualifications of xuexin.com
2022.02.13 - NC003. Design LRU cache structure
【ROS】usb_cam相机标定
2022 Inner Mongolia latest water conservancy and hydropower construction safety officer simulation examination questions and answers
Charging interface docking tutorial of enterprise and micro service provider platform
Colorlog combined with logging to print colored logs
VMware virtualization cluster
Summary of MySQL index failure scenarios
2022.02.13 - NC004. Print number of loops
704 binary search
JS pure function
PLT in Matplotlib tight_ layout()
Mobile phones and computers on the same LAN access each other, IIS settings
[cloud native topic -45]:kubesphere cloud Governance - Introduction and overall architecture of enterprise container platform based on kubernetes
2022.02.13 - 238. Maximum number of "balloons"