logo资料库

DSP 整套系统源代码.doc

第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
资料共24页,剩余部分请下载后查看
2.main() { int i; unsigned int * px; unsigned int * py; unsigned int * pz; px=(unsigned int *)0x4080; py=(unsigned int *)0x4100; for ( i=0,pz=px;i<16;i++,pz++ ) (*pz)=i; // 字地址,字节地址为 8100H // 字地址,字节地址为 8200H for ( i=0,pz=py;i<16;i++,pz++ ) // 在此加软件断点 (*pz)=0x1234; for ( i=0;i<16;i++,px++,py++ ) // 在此加软件断点 (*py)=(*px); while(1) { } // 在此加软件断点 } 3.#include "myapp.h" // 定义指示灯寄存器地址和寄存器类型 #define LBDS (*((unsigned int *)0x400001)) void INTR_init( void ); void TIMER_init(void); int nCount; main() { nCount=0; PLL_Init(40); SDRAM_init(); LBDS=0; INTR_init(); TIMER_init(); while ( 1 ) { } }
void interrupt Timer() { nCount++; nCount%=16; if ( nCount==0 ) LBDS^=1; } void INTR_init( void ) { IVPD=0xd0; IVPH=0xd0; IER0=0x10; DBIER0 =0x10; IFR0=0xffff; asm(" BCLR INTM"); } void TIMER_init(void) { ioport unsigned int *tim0; ioport unsigned int *prd0; ioport unsigned int *tcr0; ioport unsigned int *prsc0; tim0 = (unsigned int *)0x1000; prd0 = (unsigned int *)0x1001; tcr0 = (unsigned int *)0x1002; prsc0 = (unsigned int *)0x1003; *tcr0 = 0x04f0; *tim0 = 0; *prd0 = 0x0ffff; *prsc0 = 2; *tcr0 = 0x00e0; } 4.#include "myapp.h" #include "ICETEK-VC5509-EDU.h" #include "scancode.h" void InitADC(); void wait( unsigned int cycles ); void EnableAPLL( ); unsigned int nADC0[256],nADC1[256]; main() {
int i; unsigned int uWork; EnableAPLL(); SDRAM_init(); InitADC(); PLL_Init(132); while ( 1 ) { for ( i=0;i<256;i++ ) { ADCCTL=0x8000; // 启动 AD 转换,通道 0 do { uWork=ADCDATA; } while ( uWork&0x8000 ); nADC0[i]=uWork&0x0fff; } for ( i=0;i<256;i++ ) { ADCCTL=0x9000; // 启动 AD 转换,通道 1 do { uWork=ADCDATA; } while ( uWork&0x8000 ); nADC1[i]=uWork&0x0fff; } asm( " nop"); // break point } } void InitADC() { ADCCLKCTL=0x23; // 4MHz ADCLK ADCCLKDIV=0x4f00; } void wait( unsigned int cycles ) { int i; for ( i = 0 ; i < cycles ; i++ ){ } } void EnableAPLL( )
{ /* Enusre DPLL is running */ *( ioport volatile unsigned short* )0x1f00 = 4; wait( 25 ); *( ioport volatile unsigned short* )0x1f00 = 0; // MULITPLY *( ioport volatile unsigned short* )0x1f00 = 0x3000; // COUNT *( ioport volatile unsigned short* )0x1f00 |= 0x4F8; wait( 25 ); //*( ioport volatile unsigned short* )0x1f00 |= 0x800 // MODE *( ioport volatile unsigned short* )0x1f00 |= 2; wait( 30000 ); // APLL Select *( ioport volatile unsigned short* )0x1e80 = 1; // DELAY wait( 60000 ); } 5.#include "myapp.h" #include "ICETEK-VC5509-EDU.h" #include "scancode.h" #define CTRSTATUS (*(unsigned int *)0x600800) //port8000 #define CTRLED (*(unsigned int *)0x600802) // port8004 void InitMcBSP(); main() { PLL_Init(12); SDRAM_init(); InitCTR(); InitMcBSP();
CTRSTATUS=0x80; CTRSTATUS=0; CTRSTATUS=0x80; CTRSTATUS=0; CTRLED=0xff; // 使能 IO CTRGR=2; while ( 1 ) { PCR1^=8; Delay(256); } } void InitMcBSP() { // IOPin: McBSP1.FSX S15 //SPCR2.XRST_=0,PCR.XIOEN=1,PCR.FSXM=1,PCR.FSXP=0/1 SPCR2_1&=0x0fffe; PCR1|=0x2800; } 6.#include #include "volume.h" /* processing data buffers */ /* Global declarations */ int inp1_buffer[BUFSIZE]; int inp2_buffer[BUFSIZE]; int out1_buffer[BUFSIZE]; int out2_buffer[BUFSIZE]; int out3_buffer[BUFSIZE]; int out4_buffer[BUFSIZE*2]; int size = BUFSIZE; int ain = MINGAIN; int zhy=0; int sk=64; 点,sine11.dat, /*sk 代 表 所 开 的 bufsize 的 大 小, 需 修 改 它 . 输 入 文 件 sine.dat 为 32 sin22.dat,sin33.dat,sin44.dat 为 64 点的输入波形.*/ /* volume control variable */ //unsigned int processingLoad = 1; /* processing routine load value */
/* Functions */ extern void load(unsigned int loadValue); static int processing1(int *output1, int *output2); static int processing2(int *output2, int *output3); static int processing3(int *input1,int *output2,int *output4); static int processing4(int *input2, int *output1); static void dataIO1(void); static void dataIO2(void); /* * ======== main ======== */ void main() { int *input1 = &inp1_buffer[0]; int *input2 = &inp2_buffer[0]; int *output1 = &out1_buffer[0]; int *output2 = &out2_buffer[0]; int *output3 = &out3_buffer[0]; int *output4 = &out4_buffer[0]; puts("volume example started\n"); /* loop forever */ while(TRUE) { /* * Read input data using a probe-point connected to a host file. * Write output data to a graph connected through a probe-point. */ // break point // break point dataIO1(); dataIO2(); /* apply gain */ processing4(input2,output1); processing1(output1, output2); processing2(output2, output3); processing3(input1,output2,output4) ; } } /* * ======== processing ======== *
* FUNCTION: apply signal processing transform to input signal. * * PARAMETERS: address of input and output buffers. * * RETURN VALUE: TRUE. */ static int processing4(int *input2,int *output1) { int m=sk; for(;m>=0;m--) { *output1++ = *input2++ * ain; } for(;(size-m)>0;m++) {output1[m]=0; } // load(processingLoad); return(TRUE); } static int processing1(int *output1,int *output2) { int m=sk-1; for(;m>0;m--) { *output2++ = *output1++ * ain; } // /* additional processing load */ load(processingLoad); return(TRUE); } static int processing2(int *output2, int *output3) { int n=zhy; size=BUFSIZE; for(;(size-n)>0;n++) { *output3++ = output2[n]; } /* for (;n>0;n--) { *output3++ = 0; } */ // load(processingLoad); return(TRUE);
} static int processing3(int *input1,int *output2,int *output4) { int m=sk; int y=zhy; int z,x,w,i,f,g; for(;(m-y)>0;) {i=y; x=0; z=0; f=y; for(;i>=0;i--) {g=input1[z]*output2[f]; x=x+g; z++; f--; } *output4++ = x; y++; } m=sk; y=sk-1; w=m-zhy-1; for(;m>0;m--) { y--; i=y; z=sk-1; x=0; f=sk-y; for(;i>0;i--,z--,f++) {g=input1[z]*output2[f]; x=x+g; } out4_buffer[w]=x; w++; } // load(processingLoad); return(TRUE); } /* * ======== dataIO ======== * * FUNCTION: read input signal and write processed output signal.
分享到:
收藏