版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、實驗四一、實驗題目:利用ADSPBF533-EZ-KIT板的硬件資源,完成對信號的采樣和濾波分析。二、實驗?zāi)康模杭由顚?shù)字濾波這種信號處理的方法的理解。三、實驗設(shè)備:信號源、EZ-KIT板、微機、示波器等。四、實驗內(nèi)容:本實驗中提供的基本FIR濾波器程序,初始化不同的FIR濾波器的系數(shù)來設(shè)計出不同的濾波器。利用調(diào)試器的繪圖(plot)功能來顯示有關(guān)數(shù)據(jù)的波形;五、實驗原理:對信號加漢明窗可改善信號的質(zhì)量,主瓣寬,頻率分辨率較低,旁瓣也較低。對濾波器進行時域壓縮,頻域便會展寬。對濾波器進行移位,使低通變成了帶通。本實驗為了觀察這幾種變化的輸出結(jié)果的不同。六、實驗步驟:1)連接硬件關(guān)閉PC機的電源
2、,按照硬件連接圖正確連接各個硬件設(shè)備,檢查EZ-KIT板上的跳線位置是否正確,按照硬件連接圖檢查確保正確連接各個硬件設(shè)備。2)加電和啟動程序檢查無誤后,分別打開PC機、信號源、評估板和示波器的電源,運行VisualDSP+,新建一個工程,工程名稱自定義,正確設(shè)置工程的各個選項,將 test3 fir目錄下的源文件加入到工程中?;蛘叽蜷_ test3 FIR目錄下已經(jīng)存在的工程FIR.dpj。3)選擇或者建立正確的會話類型按照要求選擇或者建立EZ-KIT類型的會話,詳細要求請參閱7.4.1節(jié)的有關(guān)內(nèi)容。4) 編譯鏈接和觀察結(jié)果編譯鏈接該工程,沒有錯誤后運行程序。必須注意在Settings菜單中有幾
3、項必須正確設(shè)置,設(shè)置和運行EZ_KIT板方法請7.4.1節(jié)的有關(guān)內(nèi)容。正確的設(shè)置Settings后,才可以從示波器上看到輸出結(jié)果。5)改變信號類型觀察調(diào)節(jié)信號發(fā)生器,利用示波器監(jiān)視其輸出幅度為0.51Vpp,分別產(chǎn)生正弦波、方波和三角波,使其頻率從直流到采樣頻率連續(xù)地變化,觀察示波器上輸出信號幅度和波形的變化。6)修改源程序改變?yōu)V波狀態(tài)觀察將源程序中的window=0 修改為:window=1,然后再重復步驟4),5),記錄典型點的信號幅度數(shù)據(jù),描繪濾波器幅頻特性。將源程序中的Shift=0改為Shift=1,然后再重復步驟4),5),記錄典型點的信號幅度數(shù)據(jù),描繪濾波器幅頻特性。將源程序中的
4、Compress=0改為Compress=1,然后再重復步驟4),5),記錄典型點的信號幅度數(shù)據(jù),描繪濾波器幅頻特性。window=1表明加了漢明窗Compress=1 表明對原濾波器進行了時域壓縮。Shift=1 表明對原濾波器進行了移位,低通變?yōu)榱藥ā?、 主要源代碼:1)程序結(jié)構(gòu):程序包括主函數(shù)main()、Process_data()、Initialize()和ISR()等4個模塊,以及常數(shù)和宏定義、全局變量定義部分。其中main()函數(shù)完成程序的控制,Initialize()完成CODEC和BF533個部分的初始化,Process_data ()完成數(shù)據(jù)采集和計算,ISR()實現(xiàn)中
5、斷控制。2)程序工作流程:main()先調(diào)用Initialize()完成對CODEC、BF533以及FIR濾波器系數(shù)初始化,再調(diào)用ISR()運行中斷服務(wù)程序,在中斷服務(wù)程序中,調(diào)用子函數(shù)Process_data ()完成對信號的采集、濾波和輸出,Process_data ()的運行模式是:采樣>FIR運算>輸出>采樣>的無限循環(huán)。3)數(shù)據(jù)源選擇:變量Process_Stat為采集狀態(tài)標志位,若Process_Stat=0,則從CODEC取采樣數(shù)據(jù)存入Inbuf0;Process_Stat=1,則從CODEC取采樣數(shù)據(jù)存入Inbuf1;Process_Stat=2,則對I
6、nbuf中的數(shù)據(jù)進行濾波,然后輸出。4)濾波類型:通過濾波器類型變量filter=1,設(shè)定濾波類型為低通。濾波器的參數(shù)都放在數(shù)組變量hFIR_TAPS中。數(shù)據(jù)經(jīng)過FIR濾波器后,才送往示波器。實驗五的程序位于test3 fir子目錄,打開工程文件FIR.DPJ,可以看到演示軟件包括以下幾個程序模塊:talkthouth.h#ifndef _Talkthrough_DEFINED#define _Talkthrough_DEFINED/-/ Header files/-/#include <sysexception.h>#include <cdefBF533.h>#inc
7、lude <fract.h>#include <filter.h>/-/ Symbolic constants/-/ addresses for Port B in Flash A#define pFlashA_PortA_Dir(volatile unsigned char *)0x20270006#define pFlashA_PortA_Data(volatile unsigned char *)0x20270004/ names for codec registers, used for sCodec1836TxRegs#define DAC_CONTROL_1
8、0x0000#define DAC_CONTROL_20x1000#define DAC_VOLUME_00x2000#define DAC_VOLUME_10x3000#define DAC_VOLUME_20x4000#define DAC_VOLUME_30x5000#define DAC_VOLUME_40x6000#define DAC_VOLUME_50x7000#define ADC_0_PEAK_LEVEL0x8000#define ADC_1_PEAK_LEVEL0x9000#define ADC_2_PEAK_LEVEL0xA000#define ADC_3_PEAK_LE
9、VEL0xB000#define ADC_CONTROL_10xC000#define ADC_CONTROL_20xD000#define ADC_CONTROL_30xE000/ names for slots in ad1836 audio frame#define INTERNAL_ADC_L00#define INTERNAL_ADC_R02#define INTERNAL_DAC_L00#define INTERNAL_DAC_R02#define INTERNAL_ADC_L11#define INTERNAL_ADC_R13#define INTERNAL_DAC_L11#de
10、fine INTERNAL_DAC_R13/ size of array sCodec1836TxRegs#define CODEC_1836_REGS_LENGTH11/ SPI transfer mode#define TIMOD_DMA_TX 0x0003/ SPORT0 word length#define SLEN_240x0017/ DMA flow mode#define FLOW_10x1000/#define FIR_TAPS 256/#define BUF_FIRST 0#define BUF_SECOND 1#define BUF_FILTER 2/-/ Global v
11、ariables/-/extern int iChannel0LeftIn;extern int iChannel0RightIn;extern int iChannel0LeftOut;extern int iChannel0RightOut;extern int iChannel1LeftIn;extern int iChannel1RightIn;extern int iChannel1LeftOut;extern int iChannel1RightOut;extern volatile short sCodec1836TxRegs;extern volatile int iRxBuf
12、fer1;extern volatile int iTxBuffer1;extern fract16 coeffs;extern fract16 delay;extern fir_state_fr16 state;extern short int Process_Stat;extern int OutBufCnt;/-/ Prototypes/-/ in file Initialize.cvoid Init_EBIU(void);void Init_Flash(void);void Init1836(void);void Init_Sport0(void);void Init_DMA(void
13、);void Init_Interrupts(void);void InitCoeffs(void);void Init_ProcessData(void);void Enable_DMA_Sport(void);/ in file Process_data.cvoid Process_Data(void);/ in file ISRs.cEX_INTERRUPT_HANDLER(Sport0_RX_ISR);#endif /_Talkthrough_DEFINEDmain.c#include "Talkthrough.h"#include "sysreg.h&q
14、uot;#include "ccblkfn.h"#include <fract.h>/-/ Variables/ Description:The variables iChannelxLeftIn and iChannelxRightIn contain /the data coming from the codec AD1836. The (processed)/playback data are written into the variables /iChannelxLeftOut and iChannelxRightOut respectively, w
15、hich /are then sent back to the codec in the SPORT0 ISR. /The values in the array iCodec1836TxRegs can be modified to /set up the codec in different configurations according to /the AD1885 data sheet./-/ left input data from ad1836int iChannel0LeftIn, iChannel1LeftIn;/ right input data from ad1836in
16、t iChannel0RightIn, iChannel1RightIn;/ left ouput data for ad1836int iChannel0LeftOut, iChannel1LeftOut;/ right ouput data for ad1836int iChannel0RightOut, iChannel1RightOut;/ array for registers to configure the ad1836/ names are defined in "Talkthrough.h"volatile short sCodec1836TxRegsCO
17、DEC_1836_REGS_LENGTH =DAC_CONTROL_1| 0x000,DAC_CONTROL_2| 0x000,DAC_VOLUME_0| 0x3ff,DAC_VOLUME_1| 0x3ff,DAC_VOLUME_2| 0x3ff,DAC_VOLUME_3| 0x3ff,DAC_VOLUME_4| 0x000,DAC_VOLUME_5| 0x000,ADC_CONTROL_1| 0x000,ADC_CONTROL_2| 0x000,ADC_CONTROL_3| 0x000;/ SPORT0 DMA transmit buffervolatile int iTxBuffer14;
18、/ SPORT0 DMA receive buffervolatile int iRxBuffer14;/-/ Function:main/ Description:After calling a few initalization routines, main() just /waits in a loop forever. The code to process the incoming /data can be placed in the function Process_Data() in the /file "Process_Data.c"./-/void mai
19、n(void)sysreg_write(reg_SYSCFG, 0x32);/Initialize System Configuration RegisterInit_EBIU();Init_Flash();Init1836();InitCoeffs();Init_ProcessData();Init_Sport0();Init_DMA();Init_Interrupts();Enable_DMA_Sport0();while(1);Initialize.c#include "Talkthrough.h"#include <filter.h>fir_state_
20、fr16 state;/-/ Function:Init_EBIU/ Description:This function initializes and enables asynchronous memory /banks in External Bus Interface Unit so that Flash A can be /accessed./-/void Init_EBIU(void)*pEBIU_AMBCTL0= 0x7bb07bb0;*pEBIU_AMBCTL1= 0x7bb07bb0;*pEBIU_AMGCTL= 0x000f;/-/ Function:Init_Flash/
21、Description:This function initializes pin direction of Port A in Flash A/to output. The AD1836_RESET on the ADSP-BF533 EZ-KIT board /is connected to Port A./-/void Init_Flash(void)*pFlashA_PortA_Dir = 0x3;/-/ Function:Init1836()/ Description:This function sets up the SPI port to configure the AD1836
22、. /The content of the array sCodec1836TxRegs is sent to the /codec./-/void Init1836(void)int i;int j;static unsigned char ucActive_LED = 0x01;/ write to Port A to reset AD1836*pFlashA_PortA_Data = 0x00;/ write to Port A to enable AD1836*pFlashA_PortA_Data = ucActive_LED;/ wait to recover from resetf
23、or (i=0; i<0xf000; i+);/ Enable PF4*pSPI_FLG = FLS4;/ Set baud rate SCK = HCLK/(2*SPIBAUD) SCK = 2MHz*pSPI_BAUD = 16;/ configure spi port/ SPI DMA write, 16-bit data, MSB first, SPI Master*pSPI_CTL = TIMOD_DMA_TX | SIZE | MSTR;/ Set up DMA5 to transmit/ Map DMA5 to SPI*pDMA5_PERIPHERAL_MAP= 0x500
24、0;/ Configure DMA5/ 16-bit transfers*pDMA5_CONFIG = WDSIZE_16;/ Start address of data buffer*pDMA5_START_ADDR = sCodec1836TxRegs;/ DMA inner loop count*pDMA5_X_COUNT = CODEC_1836_REGS_LENGTH;/ Inner loop address increment*pDMA5_X_MODIFY = 2;/ enable DMAs*pDMA5_CONFIG = (*pDMA5_CONFIG | DMAEN);/ enab
25、le spi*pSPI_CTL = (*pSPI_CTL | SPE);/ wait until dma transfers for spi are finished for (j=0; j<0xaff; j+);/ disable spi*pSPI_CTL = 0x0000;/-/ Function:Init_Sport0/ Description:Configure Sport0 for I2S mode, to transmit/receive data /to/from the AD1836. Configure Sport for external clocks and /fr
26、ame syncs./-/void Init_Sport0(void)/ Sport0 receive configuration/ External CLK, External Frame sync, MSB first, Active Low/ 24-bit data, Stereo frame sync enable*pSPORT0_RCR1 = RFSR | LRFS | RCKFE;*pSPORT0_RCR2 = SLEN_24 | RXSE | RSFSE;/ Sport0 transmit configuration/ External CLK, External Frame s
27、ync, MSB first, Active Low/ 24-bit data, Secondary side enable, Stereo frame sync enable*pSPORT0_TCR1 = TFSR | LTFS | TCKFE;*pSPORT0_TCR2 = SLEN_24 | TXSE | TSFSE;/-/ Function:Init_DMA/ Description:Initialize DMA1 in autobuffer mode to receive and DMA2 in/autobuffer mode to transmit/-/void Init_DMA(
28、void)/ Set up DMA1 to receive/ Map DMA1 to Sport0 RX*pDMA1_PERIPHERAL_MAP = 0x1000;/ Configure DMA1/ 32-bit transfers, Interrupt on completion, Autobuffer mode*pDMA1_CONFIG = WNR | WDSIZE_32 | DI_EN | FLOW_1;/ Start address of data buffer*pDMA1_START_ADDR = iRxBuffer1;/ DMA inner loop count*pDMA1_X_
29、COUNT = 4;/ Inner loop address increment*pDMA1_X_MODIFY = 4;/ Set up DMA2 to transmit/ Map DMA2 to Sport0 TX*pDMA2_PERIPHERAL_MAP = 0x2000;/ Configure DMA2/ 32-bit transfers, Autobuffer mode*pDMA2_CONFIG = WDSIZE_32 | FLOW_1;/ Start address of data buffer*pDMA2_START_ADDR = iTxBuffer1;/ DMA inner lo
30、op count*pDMA2_X_COUNT = 4;/ Inner loop address increment*pDMA2_X_MODIFY = 4;/-/ Function:Enable_DMA_Sport/ Description:Enable DMA1, DMA2, Sport0 TX and Sport0 RX/-/void Enable_DMA_Sport0(void)/ enable DMAs*pDMA2_CONFIG= (*pDMA2_CONFIG | DMAEN);*pDMA1_CONFIG= (*pDMA1_CONFIG | DMAEN);/ enable Sport0
31、TX and RX*pSPORT0_TCR1 = (*pSPORT0_TCR1 | TSPEN);*pSPORT0_RCR1 = (*pSPORT0_RCR1 | RSPEN);/-/ Function:Init_Interrupts/ Description:Initialize Interrupt for Sport0 RX/-/void Init_Interrupts(void)/ Set Sport0 RX (DMA1) interrupt priority to 2 = IVG9 *pSIC_IAR0 = 0xffffffff;*pSIC_IAR1 = 0xffffff2f;*pSI
32、C_IAR2 = 0xffffffff;/ assign ISRs to interrupt vectors/ Sport0 RX ISR -> IVG 9register_handler(ik_ivg9, Sport0_RX_ISR);/ enable Sport0 RX interrupt*pSIC_IMASK = 0x00000200;/-/ Function:Init_ProcessData/ Description:Initialize Process Data for FIR/-/void Init_ProcessData(void)int i;Process_Stat=BU
33、F_FIRST;OutBufCnt=0;fir_init(state, coeffs, delay, FIR_TAPS,1);ISR.c#include "Talkthrough.h"EX_INTERRUPT_HANDLER(Sport0_RX_ISR)/ confirm interrupt handling*pDMA1_IRQ_STATUS = 0x0001;/ copy input data from dma input buffer into variablesiChannel0LeftIn = iRxBuffer1INTERNAL_ADC_L0;iChannel0R
34、ightIn = iRxBuffer1INTERNAL_ADC_R0;iChannel1LeftIn = iRxBuffer1INTERNAL_ADC_L1;iChannel1RightIn = iRxBuffer1INTERNAL_ADC_R1;/ call function that contains user codeProcess_Data();/ copy processed data from variables into dma output bufferiTxBuffer1INTERNAL_DAC_L0 = iChannel0LeftOut;iTxBuffer1INTERNAL
35、_DAC_R0 = iChannel0RightOut;iTxBuffer1INTERNAL_DAC_L1 = iChannel1LeftOut;iTxBuffer1INTERNAL_DAC_R1 = iChannel1RightOut;Process_data.c#include "Talkthrough.h"#include <filter.h>#include <fract.h>#include <math.h>#include <complex.h>#define PI3.1415926#define FC2 0.05
36、/以采樣率Fs進行歸一化的高頻截止頻率#define FC1 0.00/以采樣率Fs進行歸一化的低頻截止頻率#define FL0.2/移位量#define COEFFSCALE 20000/濾波器系數(shù)整型標尺/#define RESULT_SIZE 256/short int Process_Stat; int OutBufCnt;int Window;/加窗標志float WFIR_TAPS;/窗函數(shù)int Shift;/頻域移位標志int Compress;/時域壓縮標志int hFIR_TAPS;/最終設(shè)計的濾波器沖擊響應(yīng)fract16 delayFIR_TAPS;fract16 co
37、effsFIR_TAPS;fract16 Inbuf2;fract16 Outbuf2;int FirOutCnt;short int FirResultBufRESULT_SIZE;/-/ Function:Init_Coeffs/ Description:Initialize Process Data for FIR/-/void InitCoeffs(void)int i;float hdFIR_TAPS;/理想低通濾波器的沖擊響應(yīng)float cosineFIR_TAPS;/移位因子Window=0;Shift=0;Compress=0;/testFirOutCnt=0;/*初始化濾波器
38、系數(shù)*/濾波器系數(shù)產(chǎn)生/ for(i=0;i<(FIR_TAPS-1)/2;i+) hdi=(1/PI)*(sin(2*FC2*PI*(i-(FIR_TAPS-1)/2)-sin(2*FC1*PI*(i-(FIR_TAPS-1)/2)/(i-(FIR_TAPS-1)/2); for(i=(FIR_TAPS-1)/2+1;i<FIR_TAPS;i+) hdi=(1/PI)*(sin(2*FC2*PI*(i-(FIR_TAPS-1)/2)-sin(2*FC1*PI*(i-(FIR_TAPS-1)/2)/(i-(FIR_TAPS-1)/2);hd(FIR_TAPS-1)/2=2*(FC2
39、-FC1);/時域截取/for(i=0;i<FIR_TAPS;i+) hi=(int)(hdi*COEFFSCALE);/時域加窗/if(Window)for(i=0;i<FIR_TAPS;i+)Wi=0.54-0.46*cos(2*PI*i/(FIR_TAPS-1); for(i=0;i<FIR_TAPS;i+)hi=(int)(float)hi*Wi);/時域壓縮系數(shù)/if(Compress)for (i=0;i<FIR_TAPS/2;i+) hdi=hi*2;for (i=0;i<FIR_TAPS/2;i+) hi=hdi;for (i=FIR_TAPS/2
40、;i<FIR_TAPS;i+) hi=0;/序列右邊填零/移位FL*fs/if(Shift) for (i=0;i<FIR_TAPS;i+)cosinei=cos(2*PI*i*FL);for(i=0;i<FIR_TAPS;i+) hi=(int)(float)hi*cosinei);for(i=0;i<FIR_TAPS;i+)coeffsi=hi;/-/ Function:Process_Data()/ Description: This function is called from inside the SPORT0 ISR every /time a complete audio frame has been received. The new /input samples can be found in the variables iChannel0LeftIn,/iChannel0RightIn, iChannel1LeftIn and iChannel1Right
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年特色小鎮(zhèn)開發(fā)建設(shè)合作合同
- 職業(yè)衛(wèi)生課程設(shè)計崔曉紅
- 統(tǒng)計學課程設(shè)計作業(yè)
- 化工安全生產(chǎn)管理制度
- 自動循環(huán)配料課程設(shè)計
- 照明課程設(shè)計日志模板
- 中國石化集團公司安全生產(chǎn)監(jiān)督管理制度
- 電骰子 課程設(shè)計
- 碩士課程設(shè)計論文格式
- 自動大門plc組態(tài)課程設(shè)計
- 水利水電工程單元工程施工質(zhì)量驗收評定表及填表說明
- 2023年二輪復習解答題專題十七:二次函數(shù)的應(yīng)用(銷售利潤問題)(原卷版+解析)
- 《ISO56001-2024創(chuàng)新管理體系 - 要求》之26:“9績效評價-9.3管理評審”解讀和應(yīng)用指導材料(雷澤佳編制-2024)
- 2024至2030年中國除草劑行業(yè)市場前景預測及未來發(fā)展趨勢研究報告
- 三年級上冊乘法豎式計算練習200道及答案
- 2024-2030年中國泥炭市場深度調(diào)查研究報告
- 組建學校籃球隊方案
- 政務(wù)服務(wù)中心物業(yè)服務(wù)投標方案【新版】(技術(shù)方案)
- (正式版)YS∕T 5040-2024 有色金屬礦山工程項目可行性研究報告編制標準
- HJ 179-2018 石灰石石灰-石膏濕法煙氣脫硫工程技術(shù)規(guī)范
- JT-T-617.7-2018危險貨物道路運輸規(guī)則第7部分:運輸條件及作業(yè)要求
評論
0/150
提交評論