DSP实验源程序 下载本文

; ; ; ;

ssbx xf

NOP NOP

CALL IfTxRDY1

STM #0x0101, McBSP1_DXR1

CALL IfTxRDY1

STM #0x0208, McBSP1_DXR1

;; rsbx xf ;; NOP

;;NOP

CALL IfTxRDY1

CALL IfTxRDY1

STM #0000h, McBSP1_DXR1

NOP NOP rpt #20h

STM #0x0001, McBSP1_DXR1;request secondary communication NOP

CALL IfTxRDY1

STM #0100h, McBSP1_DXR1;write 00h to register 1

nop

CALL IfTxRDY1

STM #0x0001, McBSP1_DXR1;request secondary communication CALL IfTxRDY1

STM #0200h, McBSP1_DXR1;write 00h to register 2

CALL IfTxRDY1

STM #0000h, McBSP1_DXR1

CALL IfTxRDY1 STM #0x0001, McBSP1_DXR1;request secondary communication

CALL IfTxRDY1

STM #0300h, McBSP1_DXR1;write 00h to register 3 CALL IfTxRDY1

STM #0000h, McBSP1_DXR1

CALL IfTxRDY1 STM #0x0001, McBSP1_DXR1;request secondary communication CALL IfTxRDY1 STM #0490h, McBSP1_DXR1;write 00h to register 4 ; ; ; ; ; ; ; ;

RET NOP NOP

;bypass internal DPLL

;and select the Sample Frequency

CALL IfTxRDY1

STM #0000h, McBSP1_DXR1

CALL IfTxRDY1

STM #0x0001, McBSP1_DXR1 CALL IfTxRDY1

STM #0102h, McBSP1_DXR1 ;enable digital loopback CALL IfTxRDY1

STM #0x0001, McBSP1_DXR1 CALL IfTxRDY1

STM #0208h, McBSP1_DXR1 ;enable analog loopback

*********************

_CloseMcBSP: STM SPCR1, McBSP1_SPSA ; disable McBSP0 RX LDM McBSP1_SPSD,A

_READAD50:

AND #0xFFFE, A

STLM A, McBSP1_SPSD

STM SPCR2, McBSP1_SPSA ; disable McBSP0 TX LDM McBSP1_SPSD,A AND #0xFFFE, A

STLM A, McBSP1_SPSD RPT #5 RET NOP NOP

stm 0x00ff,ar3

stm 0x3000,ar2 loopa: CALL IfRxRDY1

ldm McBSP1_DRR1,b stl b,*ar2+

; banz loopa,*ar3-

nop nop ret nop nop

_WRITEAD50: stm stm loopb: ;

ldu

0x00ff,ar3 0x3100,ar2

CALL IfTxRDY1

*ar2+,B

and #0fffeh,b ;mask the LSB stlm B, McBSP1_DXR1 banz loopb,*ar3- nop nop ret nop nop

wait: stm 20h,ar3 loop1: stm 020h,ar4 loop2: banz

banz ret nop nop nop nop .end

loop2,*ar4- loop1,*ar3-

************************************************************************ ** End of File –– InitC5402.asm

2.ad50.cmd

MEMORY {

PAGE 0: /* program space */

VECS: origin = 0x0080, length = 0x007f /* 128bytes vector table space */ PROG: origin = 0x0100, length = 0x24ff /* 8K program memory space */ PAGE 1: /* data space */

SCRA: origin = 0x0060, length = 0x001f /* scratch pad mem space */ STCK: origin = 0x2600, length = 0x04ff /* 1K words for stack */ DAT1: origin = 0x2b00, length = 0x04ff /* 256 words for sys data */ DAT2: origin = 0x3200, length = 0x0e00 /* 12K words for appl data */ }

SECTIONS

{

.vectors : {} > VECS PAGE 0 /* interrupt vector table */ .text : {} > PROG PAGE 0 /* program code */ .data : {} > PROG PAGE 0 /* initialized data */

.coeffs : {} > PROG PAGE 0 /* initialized parameters */ .stack : {} > STCK PAGE 1 /* software stack section */ .variable : {} > DAT1 PAGE 1 /* uninitialized vars for DSP&AIC10 */ .bss : {} > DAT2 PAGE 1 /* uninitialized vars for applications */ }

3. C源程序 (1)Tonetest01.c

extern void InitC5402(void); extern void OpenMcBSP(void); extern void CloseMcBSP(void); extern void READAD50(void); extern void WRITEAD50(void);

/*********************************************************************** ** Main Function Program

***********************************************************************/ #include \ #include \ #define pi 3.1415926

void main(void) { int k=0; //

{

int x_ad,y_da; int *px = (int*)0x3000; int *py = (int*)0x3100;

for ( ; ; )

InitC5402(); /* initialize C5402 DSP */ OpenMcBSP();

for ( ; ; ) {

// for (j=0; j<=4; j++) { READAD50();

px = (int*)(0x3000); x_ad = *px;

y_da = x_ad; py = (int*)(0x3100); *py = y_da;

}

}

WRITEAD50(); k++;

} }

/*void PROCESSING(void) {

do the necessery operations here!*/

/*********************************************************************** ** End of File –– exp08.c