?? firlab.c
字號(hào):
/*****************************************************************************/
/* FIRlab.C AIC,McBSP,DMA initialization for FIR lab Filter */
/* */
/* Goal: This code performs the following functions: */
/* - toggle the three LEDs on the DSK */
/* - setup AIC (CODEC) parameters */
/* - initialize DMA Channel (CH2-input) */
/* - turn on interrupts */
/* - run forever (waiting for DMA interrupts to transfer data) */
/* */
/* Author: Scott Bland Date: 03/20/2000 */
/*****************************************************************************/
/*****************************************************************************/
/* Include Files */
/*****************************************************************************/
#include <type.h>
#include <board.h>
#include <codec.h>
#include <firlab.h>
#include <string.h>
/*****************************************************************************/
/* Function Prototypes */
/*****************************************************************************/
void delay(s16 period);
extern void DMAC2ISR();
/*****************************************************************************/
/* Global Variables */
/*****************************************************************************/
HANDLE hHandset;
unsigned int dmsefc, dmmcr, dmctr, src_addr, dst_addr;
unsigned int dmpre, dmsrcp, dmdstp, dmidx0, dmidx1, dmfri0, dmfri1, dmgsa, dmgda, dmgcr, dmgfr;
/* Create specific data section for buffer (symbol, section_name) */
#pragma DATA_SECTION(inp_buffer,"audio_buffer");
int inp_buffer[0x200];
/* Create specific data section for buffer (symbol, section_name) */
#pragma DATA_SECTION(out_buffer,"outt_buffer");
int out_buffer[0x200];
/* Create specific data section for coeffiecients */
#pragma DATA_SECTION(coeffs,"coefficients");
/* Low Pass Filter fs=16000 fc=4000Hz*/
int coeffs[16]={ -2, -30,127,372,-891, -1925, 4228, 14507,14507,4228,-1925,-891,372,127, -30,-2};
/* High Pass Filter */
// int coeffs[16]={-120,5245,-3421,2451,-11216,40,-24657,29610,29610,-24657,40,-11216,2451,-3421,5245,-120};
/* Band Pass Filter */
/* int coeffs[16]={921,-2494,137,-3654,-2485,-2063,-9015,16165,16165,-9015,-2063,-2485,-3654,137,-2494,921}; */
/* Band Stop Filter */
/* int coeffs[16]={491,165,-2159,772,-6697,10044,648,12297,12297,648,10044,-6697,772,-2159,165,491}; */
/* All Pass Filter */
/* int coeffs[16] ={32767,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; */
/* Create specific data section for delay buffer */
#pragma DATA_SECTION(delaybuff,"delayb");
int delaybuff[16]={0};
/* declare and initialize two variables for DMAC ISRs */
int frame=0;
int flag=0;
int temp;
int currbuff = 0;
/* delayptr holds the address of the start of the delay buffer */
int *delayptr1 = &(delaybuff[0]);
interrupt void DMAC2ISR();
/*****************************************************************************/
/* MAIN */
/*****************************************************************************/
void main()
{
s16 cnt=2;
/* These are the items that BIOS will set when we use it */
BSCR = 0x8806;
XPC = 0;
PMST = 0xA0;
brd_set_cpu_freq(100);
TIMER_HALT(0);
brd_set_wait_states(7, 7, 9);
TIMER_RESET(0);
IMR=0; //禁止所有中斷
/* ----------------------------------------------------- */
if(brd_init_bios())
return;
while(cnt--)
{
brd_led_toggle(BRD_LED0); //切換LED指示燈0的顯示狀態(tài)
delay(1000);
brd_led_toggle(BRD_LED1); //切換LED指示燈1的顯示狀態(tài)
delay(1000);
brd_led_toggle(BRD_LED2); //切換LED指示燈2的顯示狀態(tài)
delay(1000);
}
/* Open Handset Codec */
hHandset = codec_open(HANDSET_CODEC); /* Acquire handle to codec */
/* Set codec parameters */
codec_dac_mode(hHandset, CODEC_DAC_15BIT); /* DAC in 15-bit mode */
codec_adc_mode(hHandset, CODEC_ADC_15BIT); /* ADC in 15-bit mode */
codec_ain_gain(hHandset, CODEC_AIN_6dB); /* 6dB gain on analog input to ADC */
codec_aout_gain(hHandset, CODEC_AOUT_MINUS_6dB); /* -6dB gain on analog output from DAC */
codec_sample_rate(hHandset,SR_16000); /* 16KHz sampling rate */
/* Clear IFR */
INTR_CLR_FLAG(DMAC2);
/* Reset all DMA channels */
dma_reset_all();
/* Initialize DMA channel 2 */
dmsefc = ((DSYNC_REVT1 <<12));//DMA與McBSP1接收事件同步
dmmcr = ((AUTOINIT_ENABLE << 15) | (DINM_ENABLE << 14) | (IMOD_HALFBLOCK <<13) | (CTMOD_DEC <<12) | (INDEXMODE_NOMOD << 8) | (SPACE_DATA << 6) | (INDEXMODE_INC << 2) | (SPACE_DATA));
//設(shè)置傳輸控制模式寄存器DMMCR
//15bit AUTOINIT_ENABLE=1 使能自動(dòng)初始化
//14bit DINM_ENABLE=1 根據(jù)IMOD位產(chǎn)生中斷
//13bit IMOD_HALFBLOCK=1 幀和塊結(jié)束時(shí)都產(chǎn)生中斷
//12bit CTMOD_DEC=0 減量計(jì)數(shù)模式(多幀模式)
//10-8bit INDEXMODE_NOMOD=000 源地址模式No modify
//7-6bit SPACE_DATA=01 源地址空間為數(shù)據(jù)空間
//4-2bit INDEXMODE_INC=01 目的地址模式, 傳輸之后加1
//1-0bit SPACE_DATA=01 目的地址空間為數(shù)據(jù)空間
dmctr = 0xFF;//單元記數(shù),期望傳輸數(shù)據(jù)減
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -