当前位置:网站首页>【嵌入式】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,和采样点的频率一致。
边栏推荐
- Light of domestic games destroyed by cracking
- Research and investment forecast report of citronellol industry in China (2022 Edition)
- [MySQL] log
- Computer cleaning, deleted system files
- egg. JS getting started navigation: installation, use and learning
- 电脑清理,删除的系统文件
- PLT in Matplotlib tight_ layout()
- Colorlog结合logging打印有颜色的日志
- PC easy to use essential software (used)
- ROS编译 调用第三方动态库(xxx.so)
猜你喜欢

Detailed explanation of heap sorting

Sort according to a number in a string in a column of CSV file

MySQL learning records 12jdbc operation transactions

C语言双指针——经典题型

Marathon envs project environment configuration (strengthen learning and imitate reference actions)

ROS编译 调用第三方动态库(xxx.so)
![[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

C language double pointer -- classic question type

sublime text没关闭其他运行就使用CTRL+b运行另外的程序问题

2022.02.13 - NC003. Design LRU cache structure
随机推荐
The problem and possible causes of the robot's instantaneous return to the origin of the world coordinate during rviz simulation
Colorlog combined with logging to print colored logs
Image,cv2读取图片的numpy数组的转换和尺寸resize变化
【刷题】牛客网面试必刷TOP101
【MySQL】锁
2022 Inner Mongolia latest construction tower crane (construction special operation) simulation examination question bank and answers
egg. JS project deployment online server
Fibonacci sequence
查看局域网中电脑设备
2022.02.13 - NC004. Print number of loops
Introduction to the differences between compiler options of GCC dynamic library FPIC and FPIC
How to conduct interface test? What are the precautions? Nanny level interpretation
Colorlog结合logging打印有颜色的日志
[MySQL] log
[2022 Guangdong saim] Lagrange interpolation (multivariate function extreme value divide and conquer NTT)
On the day of resignation, jd.com deleted the database and ran away, and the programmer was sentenced
JS pure function
Leetcode question brushing (5.31) string
Golang force buckle leetcode 1020 Number of enclaves
Is it safe to open an account in Zheshang futures?