[MM32软件] 【MM32 eMiniBoard测评报告】+ 数字滤波FIR浮点库评测

[复制链接]
 楼主| 叶春勇 发表于 2020-5-13 17:12 | 显示全部楼层 |阅读模式
【MM32 eMiniBoard测评报告】+ 数字滤波FIR浮点库评测
步骤与FTT类似引入cmsis dsp库。
数据长度320,
x=sin(2*pi*20*t/320)
从mm32debug查看y输出的数据为:




mm32_fir_output_debug_window.png
 楼主| 叶春勇 发表于 2020-5-13 17:12 | 显示全部楼层
matlab输出数据:
matlab_fir_output.jpg
 楼主| 叶春勇 发表于 2020-5-13 17:14 | 显示全部楼层
arm_fir_f32库输出与matlab基本差不多。
附工程文件:

MM32_FIR_F32.zip

322.66 KB, 下载次数: 15

 楼主| 叶春勇 发表于 2020-5-13 17:15 | 显示全部楼层
  1. #include "arm_math.h"
  2. #include "MM32L0xx.h"
  3. #include "math.h"
  4. #define M_PI 3.1415926
  5. #define NUM_TAPS 29
  6. #define BLOCK_SIZE 32
  7. #define LEN_OF_SIG 320

  8. extern uint32_t SystemCoreClock;
  9. volatile uint32_t ticks=0;
  10. uint32_t numBlocks=LEN_OF_SIG/BLOCK_SIZE;

  11. uint32_t blockSize=32;
  12. static float32_t x[LEN_OF_SIG];
  13. static float32_t y[LEN_OF_SIG];
  14. static float32_t firStateF32[BLOCK_SIZE+NUM_TAPS-1];

  15. const float32_t coeffs[29] = {
  16.   -0.001822523074,-0.001587929321,1.226008847e-018, 0.003697750857, 0.008075430058,
  17.    0.008530221879,-4.273456581e-018, -0.01739769801, -0.03414586186, -0.03335915506,
  18.   8.073562366e-018,  0.06763084233,   0.1522061825,   0.2229246944,   0.2504960895,
  19.      0.2229246944,   0.1522061825,  0.06763084233,8.073562366e-018, -0.03335915506,
  20.    -0.03414586186, -0.01739769801,-4.273456581e-018, 0.008530221879, 0.008075430058,
  21.    0.003697750857,1.226008847e-018,-0.001587929321,-0.001822523074
  22. };

  23.        
  24. void SysTick_init()
  25. {
  26.     if (SysTick_Config(SystemCoreClock / 10000))
  27.     {
  28.         /* Capture error */
  29.         while (1);
  30.     }
  31.     /* Configure the SysTick handler priority */
  32.     NVIC_SetPriority(SysTick_IRQn, 0x0);//SysTick中断优先级设置
  33. }

  34. void SysTick_Handler(void)
  35. {
  36.         ticks++;
  37. }

  38. static void arm_fir_f32_lp(void)
  39. {
  40.         uint32_t i=0;
  41.         arm_fir_instance_f32 S;
  42.         float32_t *input,*output;
  43.         input=&x[0];
  44.         output=&y[0];
  45.        
  46.         arm_fir_init_f32(&S,NUM_TAPS,(float32_t *)&coeffs[0],&firStateF32[0],blockSize);
  47.        
  48.         for(i=0;i<numBlocks;i++)
  49.         {
  50.                 arm_fir_f32(&S,input+(i*blockSize),output+(i*blockSize),blockSize);
  51.         }
  52. }
  53. int main(void)
  54. {
  55.         uint32_t i=0;
  56.         for(i=0;i<LEN_OF_SIG;i++)
  57.         {
  58.                 x[i]=sin(2.0*M_PI*20*i/LEN_OF_SIG);
  59.         }
  60.         while(1)
  61.         {
  62.                 arm_fir_f32_lp();
  63.         }
  64. }




 楼主| 叶春勇 发表于 2020-5-13 18:35 | 显示全部楼层
用matlab命令行设计fir低通代码:
  1. clear all;
  2. clc;
  3. fs=1000
  4. fc=150
  5. wc=2*fc/fs
  6. b=fir1(28,wc)
 楼主| 叶春勇 发表于 2020-5-13 18:37 | 显示全部楼层
用matlab,fdatool设计
fdatool_LP.jpg
您需要登录后才可以回帖 登录 | 注册

本版积分规则

151

主题

4810

帖子

50

粉丝
快速回复 在线客服 返回列表 返回顶部