DSP

TMS320C5509A 控制DDS AD9854芯片进行AM幅度调制时的FIR滤波处理

2019-07-13 20:52发布

接上一节https://blog.csdn.net/pxy198831/article/details/87017571

TMS320C5509A 控制DDS AD9854芯片进行AM幅度调制

话音信号处理都少不了要用滤波,一般用FIR滤波比较多, 5509有数学LIB库可以直接调用,但是参数需要MATLAB生成 。 程序如下: fir((DATA *)&I_Q_result, (DATA *)B_BS,(DATA *)&I_Q_result, BS_dbuf,1,BL_BS); 相关的定义如下 int I_Q_result; typedef short DATA; #pragma DATA_SECTION(BP_dbuf,".globe_para"); DATA BP_dbuf[300]; #pragma DATA_SECTION(BP_dbuf_out,".globe_para"); DATA BP_dbuf_out[300]; #pragma DATA_SECTION(BS_dbuf,".globe_para"); DATA BS_dbuf[400]; 在CMD文件中(见https://blog.csdn.net/pxy198831/article/details/86582628DSP TMS320C5509A之初始化(二)) .globe_para : {}> DARAM2 PAGE 0 然后是关键的FIR参数,用MATLAB的FDATOOLS生成 根据需要选择合适的FIR滤波器数学模型,选择BANDPASS,带通,音频信号根据需要选择高低频率截止点和带内不平度,观察实际的频响,选择合适的阶数。采样率FS根据AD的采样率设置为44.1KHz 然后生成C头文件。 单击上图中的"Target" 下面的“generate C header” ,选择生成int型参数如下: /* * Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool * * Generated by MATLAB(R) 7.0 and the * * Generated on: 06-May-2015 14:38:08 * */ /* * Discrete-Time FIR Filter (real) * ------------------------------- * Filter Structure : Direct-Form FIR * Filter Order : 300 * Stable : Yes * Linear Phase : Yes (Type 1) */ /* General type conversion for MATLAB generated C-code */ #include "tmwtypes.h" /* * Expected path to tmwtypes.h * D:MATLAB7externinclude mwtypes.h */ /* * Warning - Filter coefficients were truncated to fit specified data type. * The resulting response may not match generated theoretical response. * Use the Filter Design & Analysis Tool to design accurate fixed-point * filter coefficients. */ const int BL_BS = 301; const int16_T B_BS[301] = { 3, 4, 6, 7, 6, 5, 3, 1, 0, 0, 2, 5, 9, 12, 13, 12, 10, 6, 1, -1, -1, 2, 7, 13, 19, 21, 20, 15, 7, 0, -6, -7, -3, 6, 16, 24, 29, 27, 19, 6, -7, -16, -19, -14, -2, 13, 27, 33, 31, 19, 0, -20, -36, -41, -35, -19, 3, 22, 33, 30, 13, -14, -44, -67, -78, -71, -50, -19, 9, 26, 24, 2, -36, -79, -114, -131, -125, -96, -54, -13, 13, 13, -15, -66, -125, -176, -203, -197, -160, -102, -44, -4, 2, -32, -99, -180, -253, -293, -290, -241, -162, -77, -16, -1, -41, -128, -240, -343, -405, -406, -341, -230, -106, -10, 24, -22, -139, -297, -449, -548, -559, -472, -308, -116, 43, 115, 66, -101, -344, -594, -771, -810, -684, -415, -72, 241, 418, 378, 97, -376, -926, -1389, -1594, -1404, -755, 317, 1679, 3118, 4388, 5258, 5568, 5258, 4388, 3118, 1679, 317, -755, -1404, -1594, -1389, -926, -376, 97, 378, 418, 241, -72, -415, -684, -810, -771, -594, -344, -101, 66, 115, 43, -116, -308, -472, -559, -548, -449, -297, -139, -22, 24, -10, -106, -230, -341, -406, -405, -343, -240, -128, -41, -1, -16, -77, -162, -241, -290, -293, -253, -180, -99, -32, 2, -4, -44, -102, -160, -197, -203, -176, -125, -66, -15, 13, 13, -13, -54, -96, -125, -131, -114, -79, -36, 2, 24, 26, 9, -19, -50, -71, -78, -67, -44, -14, 13, 30, 33, 22, 3, -19, -35, -41, -36, -20, 0, 19, 31, 33, 27, 13, -2, -14, -19, -16, -7, 6, 19, 27, 29, 24, 16, 6, -3, -7, -6, 0, 7, 15, 20, 21, 19, 13, 7, 2, -1, -1, 1, 6, 10, 12, 13, 12, 9, 5, 2, 0, 0, 1, 3, 5, 6, 7, 6, 4, 3 };