Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 echo.asm Page 1 1 page 132,60 2 ;**************************************************************************** 3 ; ECHO.ASM Rev.1.2 4 ; Example program to move audio through CS4215 5 ; This program uses 4k samples of delay 6 ; to add a noticeable echo to the audio. 7 ; 8 ; Copyright (c) MOTOROLA 1995 9 ; Semiconductor Products Sector 10 ; Digital Signal Processing Division 11 ; 12 ;****************************************************************************** 13 000040 START equ $40 14 15 P:0000 org p:0 ;RESET Vector 16 P:0000 0C0040 jmp START 17 18 P:000C org p:$000C 19 P:000C 0BF080 jsr ssi_rx_isr ;SSI RX 00009D 20 P:000E 0BF080 jsr ssi_rx_isr ;SSI RX w/Exception 00009D 21 P:0010 0BF080 jsr ssi_tx_isr ;SSI TX 0000AA 22 P:0012 0BF080 jsr ssi_tx_isr ;SSI TX w/Exception 0000AA 23 ;****************************************************************************** 24 25 ;--------------------------------------------------------------------------- 26 ; 27 ; DSP/codec initialization 28 ; 29 ;--------------------------------------------------------------------------- 30 P:0040 org p:START 31 32 P:0040 08F4BD movep #$261009,x:PLL ;set PLL for MPY of 10x 261009 33 P:0042 08F4BE movep #$0000,x:BCR ;zero wait states in all ext. memory 000000 34 P:0044 0003F8 ori #3,mr ;disable interrupts 35 P:0045 0500BB movec #0,sp ;clear hardware stack pointer 36 P:0046 0500BA move #0,omr ;mode 0: enable int. P:RAM, rst=0000 37 P:0047 364000 move #$40,r6 ; initialize stack pointer 38 P:0048 05F426 move #-1,m6 ; linear addressing FFFFFF 39 40 include 'ada_init.asm' 41 page 132,60 42 ;**************************************************************************** 43 ; ADA_INIT.ASM 44 ; Initialization program for the Crystal Semi. CS4215 A/D & 45 ; D/A Converters 46 ; 47 ; NOTES: 48 ; 1- The DSP5002EVM analog inputs are connected to "MIC" 49 ; input pins only. The "LINE" input pins are connected Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 ada_init.asm Page 2 50 ; to analog GROUND. Line level inputs are supported 51 ; by disabling the 20 dB Microphone Pre-Amplifier. 52 ; 2- As shipped, the DSP56002EVM has a 24.576 MHz crystal 53 ; connected to the XTAL2 inputs of the CD4215. Do 54 ; not select any other clock source unless the board 55 ; has been modified to support the alternate clock 56 ; source(s). 57 ; 58 ; 59 ; Copyright (c) MOTOROLA 1995 60 ; Semiconductor Products Sector 61 ; Digital Signal Processing Division 62 ; 63 ;**************************************************************************** 64 ; 65 ; portc usage: 66 ; bit8: SSI TX (from DSP to Codec) 67 ; bit7: SSI RX (from Codec to DSP) 68 ; bit6: SSI Clock 69 ; bit5: SSI Frame Sync 70 ; bit4: codec reset (from DSP to Codec) 71 ; bit3: 72 ; bit2: data/control bar 73 ; 0=control 74 ; 1=data 75 ; 76 ;**************************************************************************** 77 78 ;**************************************************************************** 79 ; Defined Constants used to construct data for the CONTROL TIME SLOTS 80 ;**************************************************************************** 81 100000 NO_PREAMP equ $100000 ;0 == enable 20 dB pre-amp 82 080000 LO_OUT_DRV equ $080000 ;0 == 2.8 Vp-p line (1V rms) 83 ;0 == 4.0 Vp-p headphones 84 ;1 == Line and Headphone 2.0Vp-p 85 HI_PASS_FILT 86 008000 equ $008000 ;0 == HPF disabled 87 SAMP_RATE_9 88 003800 equ $003800 ; 9.6 kHz sample rate 89 SAMP_RATE_48 90 003000 equ $003000 ;48 kHz sample rate 91 SAMP_RATE_32 92 001800 equ $001800 ;32 kHz sample rate 93 SAMP_RATE_27 94 001000 equ $001000 ;27.4 kHz sample rate 95 SAMP_RATE_16 96 000800 equ $000800 ;16 kHz sample rate 97 SAMP_RATE_8 98 000000 equ $000000 ; 8 kHz sample rate 99 000400 STEREO equ $000400 ;1 == stereo, 0 == mono 100 200300 DATA_8LIN equ $200300 ; 8-bit unsigned linear 101 200200 DATA_8A equ $200200 ; 8-bit A-law 102 200100 DATA_8U equ $200100 ; 8-bit u-law 103 200000 DATA_16 equ $200000 ;16-bit 2s complement linear 104 IMMED_3STATE 105 800000 equ $800000 ;1=SCLK & FS 3-state immediately Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 ada_init.asm Page 3 106 XTAL2_SELECT 107 200000 equ $200000 ;REQUIRED as this is the only clock 108 ; source on the board 109 000000 BITS_64 equ $000000 ; 64 bits per frame 110 040000 BITS_128 equ $040000 ;128 bits per frame 111 080000 BITS_256 equ $080000 ;256 bits per frame 112 CODEC_MASTER 113 020000 equ $020000 ;1 == codec generates SCLK & FS 114 ;0 == codec receives SCLK & FS 115 CODEC_TX_OFF 116 010000 equ $010000 ;0 == enable codec TX to DSP 117 ;1 == disable (Hi-Z) codec output 118 119 ;**************************************************************************** 120 ; Defined Constants used to construct data for the DATA TIME SLOTS (5-8) 121 ;**************************************************************************** 122 HEADPHONE_EN 123 800000 equ $800000 ;1 == headphone output enabled, 0 == muted 124 400000 LINEOUT_EN equ $400000 ;1 == line output enabled, 0 == muted 125 010000 LEFT_ATTN equ $010000 ;63 steps * 1.5 dB = -94.5 dB 126 004000 SPEAKER_EN equ $004000 ;1 == speaker output enabled, 0 == muted 127 000100 RIGHT_ATTN equ $000100 ;63 steps * 1.5 dB = -94.5 dB 128 MIC_IN_SELECT 129 100000 equ $100000 ;1 == A/D inputs from MIC pins NOTE: the 130 ; DSP56002EVM uses these pins. The line 131 ; input pins are not used. 132 010000 LEFT_GAIN equ $010000 ;15 steps * 1.5 dB = 22.5 dB 133 MONITOR_ATTN 134 001000 equ $001000 ;15 steps * 6.0 dB = 90.0 dB (mute) 135 000100 RIGHT_GAIN equ $000100 ;15 steps * 1.5 dB = 22.5 dB 136 137 ;---------------------------------------------------------------------------- 138 ; constructed constants for codec set up/initialize 139 ;---------------------------------------------------------------------------- 140 30B400 CTRL_WD_12 equ NO_PREAMP+HI_PASS_FILT+SAMP_RATE_48+STEREO+DATA_16 ;CLB=0 141 A20000 CTRL_WD_34 equ IMMED_3STATE+XTAL2_SELECT+BITS_64+CODEC_MASTER 142 000000 CTRL_WD_56 equ $000000 143 000000 CTRL_WD_78 equ $000000 144 145 ;---------------------------------------------------------------------------- 146 ; constructed constants for codec data mode 147 ;---------------------------------------------------------------------------- 148 C40000 OUTPUT_SET equ HEADPHONE_EN+LINEOUT_EN+(LEFT_ATTN*4) 149 10F400 INPUT_SET equ MIC_IN_SELECT+(15*MONITOR_ATTN)+(RIGHT_ATTN*4) 150 151 ;---DSP56002 on-chip peripheral addresses 152 00FFFF IPR equ $FFFF ;Interrupt Priority Register 153 00FFFE BCR equ $FFFE ;Bus Control Register 154 00FFFD PLL equ $FFFD ;PLL Control Register 155 00FFEF SSIDR equ $FFEF ;SSI Data Register 156 00FFEE SSISR equ $FFEE ;SSI Status Register 157 00FFED CRB equ $FFED ;SSI Control Register B 158 00FFEC CRA equ $FFEC ;SSI Control Register A 159 00FFE5 PCD equ $FFE5 ;Port C Data Register 160 00FFE3 PCDDR equ $FFE3 ;Port C Data Direction Register 161 00FFE1 PCC equ $FFE1 ;Port C Control Register Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 ada_init.asm Page 4 162 00FFE0 PBC equ $FFE0 ;Port B Control Register 163 164 165 ;---------------------------------------------------------------------------- 166 ; The two buffers which are defined below are the source and 167 ; destination storage for the codec Input/Output ISRs 168 ;---------------------------------------------------------------------------- 169 X:0000 org x:0 170 RX_BUFF_BASE 171 000000 equ * 172 RX_data_1_2 173 X:0000 ds 1 ;data time slot 1/2 for RX ISR 174 RX_data_3_4 175 X:0001 ds 1 ;data time slot 3/4 for RX ISR 176 RX_data_5_6 177 X:0002 ds 1 ;data time slot 5/6 for RX ISR 178 RX_data_7_8 179 X:0003 ds 1 ;data time slot 7/8 for RX ISR 180 181 TX_BUFF_BASE 182 000004 equ * 183 TX_data_1_2 184 X:0004 ds 1 ;data time slot 1/2 for TX ISR 185 TX_data_3_4 186 X:0005 ds 1 ;data time slot 3/4 for TX ISR 187 TX_data_5_6 188 X:0006 ds 1 ;data time slot 5/6 for TX ISR 189 TX_data_7_8 190 X:0007 ds 1 ;data time slot 7/8 for TX ISR 191 192 X:0008 RX_PTR ds 1 ; Pointer for rx buffer 193 X:0009 TX_PTR ds 1 ; Pointer for tx buffer 194 195 196 197 ;*************************************************************************** 198 ;***** initialize the CS4215 codec ***** 199 ;*************************************************************************** 200 ; 1. Configure the SSI port and the GPIO lines used (D/C~ & Reset) 201 ; 2. Select Control Mode and reset the codec (50ms @ 40MHz) 202 ; 3. Initialize the Transmit Data Buffer with Control Words (CLB=0) 203 ; 4. Enable SSI 204 ; 5. Wait until CLB in receive buffer = 0 205 ; 6. Set CLB = 1 in TX buffer 206 ; 7. Send 4 frames of data 207 ; 8. Disable SSI port 208 ; 9. Program SSI to receive Frame Sync and Clock 209 ; 10. Select Data Mode (D/C~ = 1) 210 ; 11. Enable SSI port 211 ;*************************************************************************** 212 ; 213 ; 214 P:004A org p: 215 codec_init 216 P:004A 240000 move #RX_BUFF_BASE,x0 217 P:004B 440800 move x0,x:RX_PTR ; Initialize the rx pointer Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 ada_init.asm Page 5 218 P:004C 240400 move #TX_BUFF_BASE,x0 219 P:004D 440900 move x0,x:TX_PTR ; Initialize the tx pointer 220 221 222 ;----- initialize SSI ----- 223 ; Assuming the DSP56002 is running at 40 MHz, this section selects a 224 ; 2.5 MHz SSI clock to be sent from the 56002's SSI clock circuit 225 ; to the codec. It also sets up 64-bit frame length (4 words per 226 ; frame x 16-bits per word), enables SSI TX & RX, enables TX & RX 227 ; interrupts and synchronous operation with bit-length frame sync. 228 ;---------------------------------------------------------------------------- 229 P:004E 08F4A1 movep #$0000,x:PCC ; turn off ssi port 000000 230 P:0050 08F4AC movep #$4303,x:CRA ; 40MHz/16 = 2.5MHz SCLK, WL=16 bits, 4W/F 004303 231 P:0052 08F4AD movep #$FB30,x:CRB ; RIE,TIE,RE,TE, NTWK, SYN, FSR/RSR->bit 00FB30 232 P:0054 08F4A3 movep #$14,x:PCDDR ; setup pc2 and pc4 as outputs 000014 233 P:0056 08F4A5 movep #$0,x:PCD ; D/C~ and RESET~ = 0 ==> control mode 000000 234 ;----reset delay for codec ---- 235 P:0058 06F481 do #500,_delay_loop 00005B 236 P:005A 06D0A7 rep #2000 ; 100 us delay 237 P:005B 000000 nop 238 _delay_loop 239 P:005C 0AA524 bset #4,x:PCD ; RESET~ = 1 240 P:005D 08F4BF movep #$3000,x:IPR ; set interrupt priority level 003000 241 P:005F 08F4A1 movep #$01E8,x:PCC ; Turn on ssi port 0001E8 242 243 244 ;--- set up the TX buffer with control mode data 245 P:0061 44F400 move #CTRL_WD_12,x0 30B400 246 P:0063 440400 move x0,x:TX_BUFF_BASE 247 P:0064 24A200 move #CTRL_WD_34,x0 248 P:0065 440500 move x0,x:TX_BUFF_BASE+1 249 P:0066 240000 move #CTRL_WD_56,x0 250 P:0067 440600 move x0,x:TX_BUFF_BASE+2 251 P:0068 240000 move #CTRL_WD_78,x0 252 P:0069 440700 move x0,x:TX_BUFF_BASE+3 253 254 P:006A 00FCB8 andi #$FC,mr ; enable interrupts 255 256 ; 257 ; CLB == 0 in TX Buffer, wait for CLB == 1 in RX Buffer 258 ; 259 P:006B 0AAE83 jclr #3,x:SSISR,* ; wait until rx frame bit==1 00006B 260 P:006D 0AAEA3 jset #3,x:SSISR,* ; wait until rx frame bit==0 00006D 261 P:006F 0AAE83 jclr #3,x:SSISR,* ; wait until rx frame bit==1 00006F Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 ada_init.asm Page 6 262 P:0071 0A00B2 jset #18,x:RX_BUFF_BASE,* ; loop until CLB set 000071 263 264 ; 265 ; CLB == 1 in RX Buffer, send 4 frames and then disable SSI 266 ; 267 P:0073 0A0432 bset #18,x:TX_BUFF_BASE ;set CLB 268 P:0074 060480 do #4,_init_loopB ; Delay as 4 full frames to pass 000079 269 P:0076 0AAE82 jclr #2,x:SSISR,* ; wait until tx frame bit==1 000076 270 P:0078 0AAEA2 jset #2,x:SSISR,* ; wait until tx frame bit==0 000078 271 _init_loopB 272 P:007A 08F4A1 movep #0,x:PCC ;reset SSI port (disable SSI...) 000000 273 274 ; 275 ; now CLB should be 1 -- re-program fsync and sclk direction to input 276 ; 277 ; movep #$4303,x:CRA ; 16bits,4 word/frame, /2/4/2=2.5 MHz 278 P:007C 08F4AD movep #$FB00,x:CRB ; rcv,xmt & int ena,netwk,syn,sclk==inp,msb 1st 00FB00 279 P:007E 08F4A5 movep #$14,x:PCD ; D/C~ pin = 1 ==> data mode 000014 280 P:0080 08F4A1 movep #$01E8,x:PCC ; turn on ssi port (enable SSI now...) 0001E8 281 ;-------------------------------------------------------------------------- 282 ; this is the end of the ada_init.asm routine...the main program continues 283 ;-------------------------------------------------------------------------- 284 285 286 ;****************************************************************************** 287 ; the following two EQUates will define the operatonal parameters 288 ; of the codec. Please refer to the ADA_INIT.ASM source file 289 ; for a description of the parameters selections available. The 290 ; variables defined by the EQUates are sent to the codec via 291 ; the transmit buffer, TX_BUFF. 292 ; 293 ; Since the parameters are defined in ADA_INIT.ASM, these line must 294 ; follow the include statement. 295 ;****************************************************************************** 296 297 TONE_OUTPUT 298 C40400 EQU HEADPHONE_EN+LINEOUT_EN+(4*LEFT_ATTN)+(4*RIGHT_ATTN) 299 10F000 TONE_INPUT EQU MIC_IN_SELECT+(15*MONITOR_ATTN) 300 301 302 P:0082 64F400 move #$4000,r4 004000 303 P:0084 05F424 move #$3FFF,m4 003FFF 304 loop_1 305 P:0086 0AAEA2 jset #2,x:SSISR,* ; Wait for frame sync to pass. 000086 306 P:0088 0AAE82 jclr #2,x:SSISR,* ; Wait for frame sync. Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 echo.asm Page 7 000088 307 308 P:008A 568000 move x:RX_BUFF_BASE,a ;get new samples 309 P:008B 578100 move x:RX_BUFF_BASE+1,b 310 P:008C 44E422 asr a x:(r4),x0 ;divide them by 2 and get oldest 311 P:008D 4EE42A asr b y:(r4),y0 ; samples from buffer 312 P:008E 200040 add x0,a ;add the new samples and the old 313 P:008F 200058 add y0,b 314 P:0090 200022 asr a ;reduce magnitude of new data 315 P:0091 20002A asr b 316 P:0092 566400 move a,x:(r4) ;save the altered samples 317 P:0093 5F5C00 move b,y:(r4)+ ; and bump the pointer 318 319 P:0094 560400 move a,x:TX_BUFF_BASE ; Put value in left channel tx. 320 P:0095 570500 move b,x:TX_BUFF_BASE+1 ; Put value in right channel tx. 321 P:0096 46F400 move #TONE_OUTPUT,y0 ; headphones, line out, mute spkr, no attn. C40400 322 P:0098 460600 move y0,x:TX_BUFF_BASE+2 323 P:0099 46F400 move #TONE_INPUT,y0 ; no input gain, monitor mute 10F000 324 P:009B 460700 move y0,x:TX_BUFF_BASE+3 325 P:009C 0C0086 jmp loop_1 ; Loop back. 326 327 ;----- the following line adds the interrupt service routines to the program 328 include 'txrx_isr.asm' 329 page 132 330 ;***************************************************************************** 331 ; TXRX_ISR.ASM 332 ; This file contains the basic Interrupt Service Routines (ISR) 333 ; used to service the SSI Transmit and SSI Receive Interrupts: 334 ; ssi_rx_isr 335 ; ssi_tx_isr 336 ; 337 ; Before using these routines, the appropriate interrupt 338 ; vectors must be initialized to jump to the associated 339 ; handler. (e.g., P:$000C, the SSI RX interrupt vector should 340 ; have an instruction which forces the DSP to jump to the 341 ; address of ssi_rx_isr). In addition, the DSP's Interrupt 342 ; Priority Register (IPR) must choose an interrupt level for 343 ; the SSI interrupts and the DSP56002's Mode Register must 344 ; enable that interrupt level. 345 ; 346 ; The ISRs which follow require that r6 has been established as 347 ; a pointer to a stack which grows towards increasing addresses. 348 ;***************************************************************************** 349 ; 350 ; Copyright (c) MOTOROLA 1995 351 ; Semiconductor Products Sector 352 ; Digital Signal Processing Division 353 ; 354 ;***************************************************************************** 355 356 357 ;-------------------------------------------------------------------- 358 ; SSI Receive ISR 359 ; This Interrupt Service Routine is the destination of the SSI RX Motorola DSP56000 Assembler Version 5.3.2 95-10-20 22:42:21 txrx_isr.asm Page 8 360 ; vector located at p:$000C. In many cases the SSI RX w/Exception 361 ; vector will also jump here. 362 ; R6 should point to the first free location on the stack (in X:memory). 363 ; The data is placed in a 1 frame (4 word) buffer and sync. 364 ; is verified/restored every frame. 365 ;-------------------------------------------------------------------- 366 ssi_rx_isr 367 P:009D 605E00 move r0,x:(r6)+ ; Save r0 to the stack. 368 P:009E 055E20 move m0,x:(r6)+ ; Save m0 to the stack. 369 P:009F 0503A0 move #3,m0 ; Modulo 4 buffer. 370 P:00A0 608800 move x:RX_PTR,r0 ; Load the pointer to the rx buffer. 371 P:00A1 0AAE83 jclr #3,x:SSISR,next_rx ; If not fr. syc, jump to receive data. 0000A5 372 P:00A3 300000 move #RX_BUFF_BASE,r0 ; If frame sync, reset base pointer. 373 P:00A4 000000 nop 374 next_rx 375 P:00A5 0858AF movep x:SSIDR,x:(r0)+ ; Read out received data to buffer. 376 P:00A6 600800 move r0,x:RX_PTR ; Update rx buffer pointer. 377 P:00A7 05FE20 move x:-(r6),m0 ; Restore m0. 378 P:00A8 60FE00 move x:-(r6),r0 ; Restore r0. 379 P:00A9 000004 rti 380 381 382 ;-------------------------------------------------------------------- 383 ; SSI Transmit ISR 384 ; This Interrupt Service Routine is the destination of the SSI TX 385 ; vector located at p:$0010. In many cases the SSI TX w/Exception 386 ; vector will also jump here. 387 ; R6 should point to the first free location on the stack (in X:memory). 388 ; The data is taken from a 1 frame (4 word) buffer and sync. 389 ; is verified/restored every frame. 390 ;-------------------------------------------------------------------- 391 ssi_tx_isr 392 P:00AA 605E00 move r0,x:(r6)+ ; Save r0 to the stack. 393 P:00AB 055E20 move m0,x:(r6)+ ; Save m0 to the stack. 394 P:00AC 0503A0 move #3,m0 ; Modulus 4 buffer. 395 P:00AD 608900 move x:TX_PTR,r0 ; Load the pointer to the tx buffer. 396 P:00AE 0AAE82 jclr #2,x:SSISR,next_tx ; If not frame sync, jump to transmit data. 0000B2 397 P:00B0 300500 move #TX_BUFF_BASE+1,r0 ; If frame sync, reset pointer. 398 P:00B1 000000 nop 399 next_tx 400 P:00B2 08D8AF movep x:(r0)+,x:SSIDR ; SSI transfer data register. 401 P:00B3 600900 move r0,x:TX_PTR ; Update tx buffer pointer. 402 P:00B4 05FE20 move x:-(r6),m0 ; Restore m0. 403 P:00B5 60FE00 move x:-(r6),r0 ; Restore r0. 404 P:00B6 000004 rti 405 406 407 end 0 Errors 0 Warnings