;*************************************************************************** ;QS_ST.ASM : WILL PASS AUDIO STRAIGHT THROUGH ;*************************************************************************** nolist include 'ioequ.asm' include 'intequ.asm' include 'ada_equ.asm' include 'vectors.asm' list ;****************************************************************************** ;---Buffer for talking to the CS4215 org x:0 RX_BUFF_BASE equ * RX_data_1_2 ds 1 ;data time slot 1/2 for RX ISR RX_data_3_4 ds 1 ;data time slot 3/4 for RX ISR RX_data_5_6 ds 1 ;data time slot 5/6 for RX ISR RX_data_7_8 ds 1 ;data time slot 7/8 for RX ISR TX_BUFF_BASE equ * TX_data_1_2 ds 1 ;data time slot 1/2 for TX ISR TX_data_3_4 ds 1 ;data time slot 3/4 for TX ISR TX_data_5_6 ds 1 ;data time slot 5/6 for TX ISR TX_data_7_8 ds 1 ;data time slot 7/8 for TX ISR RX_PTR ds 1 ; Pointer for rx buffer TX_PTR ds 1 ; Pointer for tx buffer ;TONE_OUTPUT EQU HEADPHONE_EN+LINEOUT_EN+(4*LEFT_ATTN)+(4*RIGHT_ATTN) ;TONE_INPUT EQU MIC_IN_SELECT+(15*MONITOR_ATTN) ;CTRL_WD_12 equ NO_PREAMP+HI_PASS_FILT+SAMP_RATE_48+STEREO+DATA_16 ;CLB=0 ;CTRL_WD_34 equ IMMED_3STATE+XTAL1_SELECT+BITS_64+CODEC_MASTER ;CTRL_WD_56 equ $000000 ;CTRL_WD_78 equ $000000 CTRL_WD_12 equ MIN_LEFT_ATTN+MIN_RIGHT_ATTN+LIN2+RIN2 CTRL_WD_34 equ MIN_LEFT_GAIN+MIN_RIGHT_GAIN org p:$50 ;SCI Recieve Data Interrupt jsr ISCIRD org p:$100 START main movep #$040003,x:M_PCTL ; set PLL for MPY of 4X movep #$012421,x:M_BCR ; set up one ext. wait state for all AAR areas ori #3,mr ;mask interrupts movec #0,sp ;clear hardware stack pointer move #0,omr ;operating mode 0 move #$40,r6 ; initialise stack pointer move #-1,m6 ; linear addressing jsr ada_init ; initialize codec ; initialize SCI ; 10-bit asynchronous mode ; enable reciever and transmitter movep #$000B02,x:M_SCR ; SCI control register ; set interrupt priority for SCI RECV to 1 move x:M_IPRP,a ; enable tx and rx pins movep #$000003,x:M_PCRE ; Port E Control Register or #000080,a ; interrupt priority 2 ; Reciever/Transmitter clocks use external clock from SCLK movep #$00C000,x:M_SCCR ; SCI Clock Control Register move a,x:M_IPRP ; interrupt priority peripheral ;print a greeting and instructions move #greet,r5 jsr print ; move #$123456,a1 ; move #$789abc,a0 ; move a,y0 ; debug loop_1 jset #2,x:M_SSISR0,* ;wait for frame sync to pass jclr #2,x:M_SSISR0,* ;wait for frame sync move x:RX_BUFF_BASE,a ;receive left move x:RX_BUFF_BASE+1,b ;receive right jsr process_stereo move a,x:TX_BUFF_BASE ;transmit left move b,x:TX_BUFF_BASE+1 ;transmit right move #CTRL_WD_12,y0 ;set up control words move y0,x:TX_BUFF_BASE+2 move #CTRL_WD_12,y0 move y0,x:TX_BUFF_BASE+3 jmp loop_1 process_stereo move a,y:newa ;store new right channel value move b,y:newb ;store new left channel value move y:diff,y0 ;load max delta mask into y0 move y:newa,a move y:olda,b ;new in a, old in b sub b,a ; get difference move a,y:temp ; hold difference in temp abs a ; check to see if it is in range cmp y0,a blt gooda move y:temp,a tst a bgt posa move y:diff,a neg a move a,y:temp bra gooda posa move y:diff,a move a,y:temp gooda move y:temp,a add b,a ;add delta back in move a,y:olda ; store new value move y:newb,a move y:oldb,b ;new in a, old in b sub b,a ; get difference move a,y:temp ; hold difference in temp abs a ; check to see if it is in range cmp y0,a blt goodb move y:temp,a tst a bgt posb move y:diff,a neg a move a,y:temp bra goodb posb move y:diff,a move a,y:temp goodb move y:temp,a add b,a ;add delta back in move a,y:oldb ; store new value move y:olda,a move y:oldb,b rts ;print subroutine takes address in register r5 ;exits when most significant byte is zero ;ignores zeros in lower bytes ; clobbers accumulator A and B and register r5 print prbegin move y:(r5)+,a ; cmp #$00ffff,a ;check to see if done (char=$00) ; blt prend cmp #$000000,a ;check to see if done (char=$00) beq prend jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish move a,x:M_STXH ; send high byte and #$00ffff,a cmp #$0000ff,a blt prbegin jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish move a,x:M_STXM ; send mid byte and #$0000ff,a cmp #$000000,a blt prbegin jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish move a,x:M_STXL ; send low byte bra prbegin prend rts ; the SCI interrupt is triggered when a character is received ; this function takes the character, checks to make sure it is ; in the correct range (1-9, A-G, a-g) prints a message and ; modifies the output mask for that number of bits ISCIRD move a,y0 ;back up A move x:M_SRXL,a cmp #$31,a ; >='1' blt iscend cmp #$3A,a ; <='9' blt iscnum cmp #$40,a ; >='A' blt iscend cmp #$48,a ; <='G' blt isclet cmp #$60,a ; >='a' blt iscend cmp #$67,a ; <='g' bgt iscend sub #$20,a bra isclet iscnum add #$07,a isclet add #$09,a isciup jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish movep #$0d,x:M_STXL ;print LF move #$800000,b ;initial mask move a,y:temp ;hold onto value temporarially sub #$41,a ; ammount to shift mask move a,y:masksz move a,x0 asr x0,b,b ; shift the mask move #>$00000f,a ;calculate bit shift ; move y:masksz,x0 sub x0,a lsr a1,b move #<$00,b2 move y:temp,a move b,y:diff sub #$10,a cmp #$3A,a ; is a 10 digit? blt isci0 isci1 jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish movep #$31,x:M_STXL sub #$0a,a isci0 jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish move a,x:M_STXL jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish movep #$20,x:M_STXL iscend move y0,a ;restore A rti include 'ada_init.asm' org y: diff dc $ffff00 masksz dc $0f temp dc $0 olda dc $0 oldb dc $0 newa dc $0 newb dc $0 greet dc $0a0d00 dc "This program demonstrates 16-bit audio sampling on the " dc $0a0d00 dc "Motorola DSP56303 with delta encoding using 1-16 bits." dc $0a0d00 dc "Attach the audio input to the Line-In jack and speakers/headphones" dc $0a0d00 dc "to the Headphone-Out jack. " dc $0a0d00 dc $0a0d00 dc "Type 1-9 or A-G to get the different max delta sizes" dc $0a0d00 dc "1=1 bit, G=16 bit" dc $0a0d00,$0a0d00 dc "Maximum Delta (bits) :" dc $0a0d00 dc "16 " dc $0 crlf dc $0a0d00,$0 ;echo end