没有合适的资源?快使用搜索试试~ 我知道了~
首页dsp实验源代码和实验报告——数据采集与FIR滤波处理
资源详情
资源评论
资源推荐
实验 11——数据采集与 FIR 滤波处理
实验11利用TS201-EZ-KIT板的硬件资源,完成对信号的采样和滤波分析。本实验中提
供的基本FIR滤波器程序,初始化不同的FIR滤波器的系数来设计出不同的滤波器。通过
这个实验加深对数字滤波这种信号处理的方法的理解。
1.实验五测试程序简介
1) 程序结构:程序包括主函数 mainA.c()、mainB.c()、inita( )、Init_audio()、InitCoeffs()
和 audio_int( )等 6 个程序模块,以及常数和宏定义、全局变量定义部分。由于实验
板上有主从两块 DSP,根据出厂设置 DSPA 为主 DSP,DSPB 为从 DSP,所以本实验
板一般兜采用了 DSPA 来处理数据,当然用户也可以自己设置主从 DSP。其中
mainA.c() 函 数 完 成 程 序 的 控 制 , InitCoeffs() 完 成 滤 波 器 系 数 的 初 始 化 设 置 ,
Init_audio()实现滤波器各参数的初始化(主要是滤波器参数 state 的获取,为后面的
滤波函数准备必备参数),inita( )完成 TS201 系统寄存器等的初始化和设置中断使能
以及传输模块 TCB 的设置、DMA 的使能启动等待 DMA 中断的到来,audio_int( )执
行中断以完成数据采集和计算。
2) 程序工作流程:mainA.c()先调用 InitCoeffs()完成滤波器系数的初始化设置,再调用
Init_audio()获取滤波器参数 state,接着调用 inita( )完成 TS201 系统寄存器等的初始化
和设置中断使能以及传输模块 TCB 的设置、DMA 的使能启动等待 DMA 中断的到来,
再调用 audio_int( )执行中断以完成数据采集和计算,在中断服务程序中,调用子函
完成对信号的采集、滤波和输出,运行模式是:采样->FIR 运算->输出->采样-
>……的无限循环。
3) 数据源选择:变量 Process_Stat 为采集状态标志位,若 Process_Stat==Sample_state,
则从 CODEC 取采样数据存入 Inputbuf[],当采集到 256 个数据后,程序会自动设置
Process_Stat==Filter_state,即进入数据处理阶段; 当 Process_Stat==Filter_state 时,
则对 Inputbuf[]中的数据进行滤波,然后输出,。
4) 滤波类型:通过滤波器类型变量 filter=1,设定滤波类型为低通。滤波器的参数都放
在数组变量 h[FIR_TAPS]中。数据经过 FIR 滤波器后,可以通过 PLOT 存储器变量观
察相应的数据。
实验五的程序位于…\ FIR子目录,打开工程文件FIR.DPJ,可以看到演示软件包括以
下几个程序模块:
1) Cache_macros.h
*******************************************************************/
/*****************************************************
-the execution of the cache commands is finished when
the bit 16 of the corresponding status registers is 0
-the macro wait_cache waits until the cache command
has finished the execution
-the 5 nops introduced at the end of the macro keep
the pipeline clean of eventual cache commands. These
cache commands may stall the processor when executed
before one cache command is ended
*/
#define wait_cache(CASTAT) \
.align_code 4; \
_chk_castat?: \
xr0 = CASTAT;; \
xbitest r0 by CASTAT_COM_ACTIVE_P;; \
.align_code 4; \
if nxseq, jump _chk_castat? (NP);nop;nop;nop;; \
nop;;nop;;nop;;nop;;nop;
/*****************************************************
-the macro test_cache_enabled tests the bit14 of the
cache status registers. If this bit is 1, the cache is enabled
and PC jumps to the following tasks. Otherwise,
the cache must be invalidated and then enabled
*/
#define test_cache_enabled(CASTAT, jump_label)\
xr0 = CASTAT;; \
xbitest r0 by CASTAT_ENBL_P;; \
if nxseq, jump jump_label (NP);; \
nop;;nop;;nop;;nop;;nop;
/*****************************************************
-the macro invalidate invalidates the cache. To enable
the cache, it must be first invalidated. This operation
basically cleans the cache.
*/
#define invalidate(CCAIR, CACMD, CASTAT) \
j0 = j31 + 0;; \
CCAIR = j0;; \
j0 = j31 + CACMD_INV | \
(127 << CACMD_LEN_P) | \
CACMD_NOSTALL;; \
CACMD = j0;; \
.align_code 4; \
_chk_castat_inv?: \
xr0 = CASTAT;; \
xbitest r0 by CASTAT_COM_ACTIVE_P;; \
.align_code 4; \
if nxseq, jump _chk_castat_inv? (NP);nop;nop;nop;;\
nop;;nop;;nop;;nop;;nop;
/*****************************************************
-the macro cache_enable executes the following operations:
-sets a new refresh rate
-if CCLK=500MHz, refresh_rate=750
-if CCLK=400MHz, refresh_rate=600
-if CCLK=300MHz, refresh_rate=450
-if CCLK=250MHz, refresh_rate=375
-tests if each cache is already enabled or not. If it
is disabled, invalidate and then enable it. If it is enabled,
don't touch it and jump to the next step.
-tests if BTB is already enabled. If not, enable the BTB
-as one may observe, after each cache command 5 nops
(i.e. 5 CCLK cycles) are introduced. This is to keep
the pipeline clean of eventual cache commands. These
cache commands may stall the processor when executed
before one cache command is ended
-it should be executed immediately after reset.
-It has not been designed to be used in the
middle of the code or in a project that uses overlays
*/
#define cache_enable(refresh_rate) \
.align_code 4; \
j0 = j31 + CACMD_REFRESH | refresh_rate;; \
CACMDALL= j0;; \
wait_cache(CASTAT0); \
wait_cache(CASTAT2); \
wait_cache(CASTAT4); \
wait_cache(CASTAT6); \
wait_cache(CASTAT8); \
wait_cache(CASTAT10); \
test_cache_enabled(CASTAT0, test_cache2); \
invalidate(CCAIR0, CACMD0, CASTAT0); \
j0 = j31 + CACMD_EN;; \
CACMD0 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT0); \
test_cache2: \
test_cache_enabled(CASTAT2, test_cache4); \
invalidate(CCAIR2, CACMD2, CASTAT2); \
j0 = j31 + CACMD_EN;; \
CACMD2 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT2); \
test_cache4: \
test_cache_enabled(CASTAT4, test_cache6); \
invalidate(CCAIR4, CACMD4, CASTAT4); \
j0 = j31 + CACMD_EN;; \
CACMD4 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT4); \
test_cache6: \
test_cache_enabled(CASTAT6, test_cache8); \
invalidate(CCAIR6, CACMD6, CASTAT6); \
j0 = j31 + CACMD_EN;; \
CACMD6 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT6); \
test_cache8: \
test_cache_enabled(CASTAT8, test_cache10); \
invalidate(CCAIR8, CACMD8, CASTAT8); \
j0 = j31 + CACMD_EN;; \
CACMD8 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT8); \
test_cache10: \
test_cache_enabled(CASTAT10, test_BTB); \
invalidate(CCAIR10,CACMD10,CASTAT10); \
j0 = j31 + CACMD_EN;; \
CACMD10 = j0;; \
nop;;nop;;nop;;nop;;nop;; \
wait_cache(CASTAT10); \
test_BTB: \
.align_code 4; \
XR0 = SQSTAT;; \
XR0 = SQSTAT;; \
XBITEST R0 BY SQSTAT_BTBEN_P;; \
IF NXSEQ, JUMP BTB_already_enabled (NP);; \
nop;;nop;;nop;;nop;;nop;; \
BTBEN;; \
.align_code 4; \
BTB_already_enabled: \
nop;
//this macro initializes the cycle counter of the benchmark
#define ini_cycle_count \
xr0 = CCNT0;; \
xr1 = 0x5;; \
xr0 = r0 + r1;; \
[j31 + cycle_count] = xr0;
//this macro computes the benchmark cycle count
剩余17页未读,继续阅读
bosonchenchen
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论4