;*************************************************************************** ;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 ; 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 y:mask,y0 and y0,a and y0,b nop rts ;print subroutine takes address in register r5 ;exits when most significant byte is zero ;ignores zeros in lower bytes ; clobbers register y0 print move a,y0 ; back up reg A prbegin move y:(r5)+,a cmp #$00ffff,a ;check to see if done (char=$00) blt 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 move y0,a ;restore reg A rts ISCIRD move a,y0 ;back up A move x:M_SRXH,a cmp #$400000,a ; >='A' blt iscend cmp #$4F0000,a ; <='P' blt isciup cmp #$600000,a ; >='a' blt iscend cmp #$6E0000,a ; <='p' bgt iscend sub #$200000,a jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish isciup move a,y:mask ;hold onto value temporarially sub #$400000,a asr #$000010,a,a move #$800000,b move a,x0 asr x0,b,b move y:mask,a move b,y:mask move #text2,r5 ; print "Sampling at " jsr print sub #$100000,a jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish cmp #$3A0000,a ; is a 10 digit? blt isci0 cmp #$440000,a ;is a 20 digit? blt isci1 movep #$320000,x:M_STXH sub #$140000,a jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish bra isci0 isci1 movep #$310000,x:M_STXH sub #$0a0000,a jclr #1,x:M_SSR,* ;wait for tx to finish jclr #0,x:M_SSR,* ;wait for tx to finish 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_STXH move #text3,r5 jsr print iscend move y0,a ;restore A rti include 'ada_init.asm' org y: mask dc $ffffff greet dc $0a0d00 dc "This program demonstrates audio sampling" dc $0a0d00 dc "at 1 to 24 bits. Attach Audio input to the" dc $0a0d00 dc "Line in Jack and speakers/headphones to the" dc $0a0d00 dc "Headphone out Jack. " dc $0a0d00 dc $0a0d00 dc "Type A-X to get the different sampling" dc $0a0d00 dc "characteristics. A=1 bit, X=24 bit" dc $0a0d00 text2 dc $0a0d00 dc "Sampling at " dc $0 text3 dc " bits" crlf dc $0a0d00,$0 text dc "Testing one two three" dc $0a0d00,$0 ;echo end