DSPRelated.com
Forums

VC33 dsk help

Started by male_uk00 June 8, 2004
im still stuck on getting my AIC loop routine to work i have some
great help from Kieth larson but i guess im just so dum

i cant see anything wrong with my code no matter how hard i look

the address in the CPLD that holds the LRCIN at base address 0x80A000
knowing the base address i can then test to see when the LRCIN bit is
a positive edge or a negative edge with in the address
that contains the 8 bit flags. With bit 4 containing the flag for
LRCIN so i dont know what i have done wrong in my code to identify the
LRCIN bit. im stuck should i give up???

: (

; **********************************************
; * Simple loopback for PCM3003 using VC33 DSK *
; **********************************************

.include "c3xmmrs.asm" ;include memory map
.start ".data",0x809C00 ;start address for
data

.data
S0_run .word 0xEBC0000 ;Set global control register
LRCIN .word 0x80A000 ;LRCIN holds the address of the
CPLD.
x_data .word 0x808048
r_data .word 0x80804c
; *********************************************
; * MAIN CODE STARTS HERE *
; ********************************************* .entry INIT_DSK ; start of code

INIT_DSK ldp @stack ; Set stack space
ldi @stack,SP ;
ldp T0_ctrl ; Use kernel data page and stack
call AIC ; Initialize the AIC

MAIN IDLE ;wait for interrupt b MAIN ; ******************************************************
; * This Code Initialises the PCM3003 Codec as well as *
; * the timer0 and serial ports for 48kHz sampling. *
; ******************************************************
;this code initialises the codec
AIC ldi 0x0,R0
sti R0,@T0_ctrl ;halt the timer
sti R0,@T0_prd ;zero out the counter
ldi 0x3,R0 ;load a count into period register
to give 12.288MHz
sti R0,@T0_prd ;Now restart the timer.
ldi 0x2C1,R0 ;this starts the timer running
sti R0,@T0_ctrl
ldi 0x111,R0 ;setup up tx and rx registers.
sti R0,@S0_xctrl
sti R0,@S0_rctrl
ldi @S0_run,R0
sti R0,@S0_gctrl ;start serial port running.
ldi 0x0,R0
sti R0,@x_data

ldi 0X0,IF
or 0X34,IE ;set the Xint0 Rint0 and int2
interupts
or 0x2000,ST ;set the global interrupt enable(bit
14 of status)
RETS
; ***********************************
; * XINT0 Interrupt Service Routine *
; ***********************************
;SAVE THE REST REGISTERS FROM THE
REGISTER FILE
XINT0 push ST ; save current status of register
pushf R0 ; save upper 32bits of R0
push R0 ; save lower 32bits R0
push AR1 ; save AR1
ldi @LRCIN,AR2 ; load address of CPLD register
into AR1
ldi *AR2,R1 ; load contents at address pointed
to by AR1 into R0

and 0x10,R1 ; this isolates the LRCIN bit

bnz right ; identify the channel ; ***********************************
; * Send Left Channel Sample Here *
; ***********************************

ldi @r_data,AR1 ; load address of CPLD register
into AR1
ldi *AR1,R0 ; load contents at address pointed
to by AR1 into R0
lsh -12,R0
sti R0,@x_data ;RESTORE THE REGISTERS FROM THE
REGISTER FILE
pop AR1 ;restore AR1
popf R0 ;restore upper 32 bits of R0
pop R0 ;restore lower 32 bits of R0
pop ST ;restore status register

reti ; ***********************************
; * RINT0 Interrupt Service Routine *
; ***********************************
;SAVE THE REST REGISTERS FROM THE
REGISTER FILE
RINT0 push ST ;save status register
pushf R0 ;save upper 32bits of R0
push R0 ;save lower 32bits of R0
push AR1 ;save AR1
ldi @LRCIN,AR2 ;
ldi *AR2,R1 ;

;Sample the LRCIN bit, and then store
the data in the right place

and 0x10,R1 ;isolated the LRCIN bit

bnz right ;identify the channel ; ***********************************
; * Send Left Channel Sample Here *
; ***********************************

ldi @r_data,AR1 ;load address of r_data into
register AR1
ldi *AR1,R0 ;put the recived value into
register RO
lsh -12,R0
sti R0,@x_data ;RESTORE THE REGISTERS FROM THE
REGISTER FILE
pop AR1 ;restore AR1
popf R0 ;restore upper 32 bits of R0
pop R0 ;restore lower 32 bits of R0
pop ST ;restore status register

reti ; ***********************************
; * Send right Channel Sample Here *
; ***********************************

right ldi @r_data,AR1 ;load address of r_data into
register AR1
ldi *AR1,R0 ;put the recived value into
register RO
lsh -12,R0
sti R0,@x_data ;RESTORE THE REGISTERS FROM THE
REGISTER FILE
pop AR1 ;restore AR1
popf R0 ;restore upper 32 bits of R0
pop R0 ;restore lower 32 bits of R0
pop ST ;restore status register

reti

;====================================================================;
; By placing the stack at the end of the users runtime code, the ;
; maximum space is made available for applications. Essentialy once ;
; used initialization code or data can be reclaimed after it is used.;
; However, use this configuration for debug purposes ;
;====================================================================;
.start "STACK",$ ; This is a reminder to put the
stack
.sect "STACK" ; stack in a safe place. $ places
stack .word stack ; section at the current assy
address
;****************************************************;
; Install the XINT/RINT ISR handler directly into ;
; the vector RAM location it will be used in ;
;****************************************************;
.start "SP0VECT1",0x809FC5
.start "SP0VECT2",0x809FC6

.sect "SP0VECT1"
BR XINT0 ; Go to routine RINT0

.sect "SP0VECT2"
BR RINT0 ; Go to routine XINT0

.end



Dont give up yet.  You are getting oh so very close!

Now that I look at this version of code, LRCIN is defined as a .word value that will load into AR1, so you can use this as a pointer.  But you still have not quite got the hang of it when it comes to direct and indirect addressing.

In particular, look at the statement where you have received data from the serial port (doing your direct followed by indirect load).  What you have done is saved R0 to the location 'x_data' so nothing ever gets put into the DAC.  Change this and you will at least get some distorted output (you have another problem).

  sti    R0,@x_data

Getting back to the direct/indirect.  The following works but is not optimal.  Read the comments here as I have made changes to them.

r_data .word S0_rdata  ; location of SP0 receive data

      ldi  @r_data,AR1 ; load address of SP0 receive data into AR1
      ldi  *AR1,R0     ; load contents at address pointed to by AR1 into R0
      lsh  -12,R0      ; use the receive data

Earlier you were very very close, but made a mistake

      ldi  @S0_rdata,AR1 ; load SP0 receive data into AR1
      ldi  *AR1,R0       ; use that *data* as a pointer to load R0
      lsh  -12,R0        ; not likely what you wanted!!!

What you should have done is simply used the data.  I was hoping that you would have picked this up rather than using the working, but not optimal solution.

      ldi  @S0_rdata,R0 ; load SP0 receive data directly into R0
      lsh  -12,R0       ; use the data

Going back to the original issue, the following line has a problem.  All it is doing is saving the value to the location @x_data which is the memory location you defined at the top of the listing.  By the way, the minimal solution will be a single line.

  sti    R0,@x_data  ; wrongo!

                     ; better, but not optimal
  ldi  @x_data,AR1   ; load address of SP0 transmit data into AR1
  sti  R0,*AR1       ; write R0 to that address

Like I said, after you fix this you should get some sound output (I did).  Your next challenge is to figure out why.  Maybe the left and right are getting confused?  Your test for the LRCIN bit is by the way OK.

Hope this helps
Keith Larson

male_uk00 wrote:
im still stuck on getting my AIC loop routine to work i have some
great help from Kieth larson but i guess im just so dum

i cant see anything wrong with my code no matter how hard i look

the address in the CPLD that holds the LRCIN at base address 0x80A000
knowing the base address i can then test to see when the LRCIN bit is
a positive edge or a negative edge with in the address
that contains the 8 bit flags. With bit 4 containing the flag for
LRCIN so i dont know what i have done wrong in my code to identify the
LRCIN bit. im stuck should i give up???

: (

; **********************************************
; * Simple loopback for PCM3003 using VC33 DSK *
; **********************************************
           .include  "c3xmmrs.asm"    ;include memory map 
           .start    ".data",0x809C00 ;start address for data
           .data
S0_run     .word  0xEBC0000       ;Set global control register
LRCIN      .word  0x80A000        ;LRCIN holds the address of the CPLD. 
x_data     .word  0x808048
r_data     .word  0x80804c
; *********************************************
; * MAIN CODE STARTS HERE                     *
; *********************************************  
          .entry   INIT_DSK      ; start of code
INIT_DSK  ldp   @stack           ; Set stack space
          ldi   @stack,SP        ;
          ldp   T0_ctrl          ; Use kernel data page and stack
          call  AIC              ; Initialize the AIC                       
MAIN      IDLE                   ; wait for interrupt
          b  MAIN
; ******************************************************
; * This Code Initialises the PCM3003 Codec as well as *
; * the timer0 and serial ports for 48kHz sampling.    *
; ******************************************************
                                 ;this code initialises the codec
AIC      ldi   0x0,R0
         sti   R0,@T0_ctrl       ;halt the timer
         sti   R0,@T0_prd        ;zero out the counter
         ldi   0x3,R0            ;load a count into period register
to give 12.288MHz
         sti   R0,@T0_prd        ;Now restart the timer. 
         ldi   0x2C1,R0          ;this starts the timer running
         sti   R0,@T0_ctrl 
         ldi   0x111,R0          ;setup up tx and rx registers.
         sti   R0,@S0_xctrl
         sti   R0,@S0_rctrl                                 
         ldi   @S0_run,R0
         sti   R0,@S0_gctrl      ;start serial port running.
         ldi   0x0,R0
         sti   R0,@x_data
         ldi  0X0,IF
         or   0X34,IE           ;set the Xint0 Rint0 and int2 interupts
         or   0x2000,ST         ;set the global interrupt enable(bit 14 of status)
          RETS
; ***********************************
; * XINT0 Interrupt Service Routine *
; ***********************************
                                   ;SAVE THE REST REGISTERS FROM THE REGISTER FILE
XINT0   push   ST                  ; save current status of register
        pushf  R0                  ; save upper 32bits of R0
        push   R0                  ; save lower 32bits R0
        push   AR1                 ; save AR1
        ldi    @LRCIN,AR2          ; load address of CPLD register into AR1
        ldi    *AR2,R1             ; load contents at address pointed to by AR1 into R0      
        and    0x10,R1             ; this isolates the LRCIN bit
        bnz    right               ; identify the channel
; ***********************************
; * Send Left Channel Sample Here   *
; ***********************************
        ldi    @r_data,AR1         ; load address of CPLD register into AR1
        ldi    *AR1,R0             ; load contents at address pointed to by AR1 into R0
        lsh    -12,R0
        sti    R0,@x_data         ;RESTORE THE REGISTERS FROM THE REGISTER FILE
        pop    AR1                ;restore AR1
        popf   R0                 ;restore upper 32 bits of R0
        pop    R0                 ;restore lower 32 bits of R0
        pop    ST                 ;restore status register
        reti
; ***********************************
; * RINT0 Interrupt Service Routine *
; ***********************************
                                  ;SAVE THE REST REGISTERS FROM THE REGISTER FILE
RINT0     push   ST               ;save status register
          pushf  R0               ;save upper 32bits of R0
          push   R0               ;save lower 32bits of R0
          push   AR1              ;save AR1
          ldi    @LRCIN,AR2       ;
          ldi    *AR2,R1          ;
                                  ;Sample the LRCIN bit, and then store the data in the right place
          and 0x10,R1           ;isolated the LRCIN bit
          bnz right             ;identify the channel 
; ***********************************
; * Send Left Channel Sample Here   *
; ***********************************
        ldi    @r_data,AR1        ;load address of r_data into register AR1
        ldi    *AR1,R0            ;put the recived value into register RO
        lsh    -12,R0
        sti    R0,@x_data         ;RESTORE THE REGISTERS FROM THE REGISTER FILE
        pop    AR1                ;restore AR1
        popf   R0                 ;restore upper 32 bits of R0
        pop    R0                 ;restore lower 32 bits of R0
        pop    ST                 ;restore status register
        reti
; ***********************************
; * Send right Channel Sample Here  *
; ***********************************
right   ldi    @r_data,AR1        ;load address of r_data into register AR1
        ldi    *AR1,R0            ;put the recived value into register RO
        lsh    -12,R0
        sti    R0,@x_data         ;RESTORE THE REGISTERS FROM THE REGISTER FILE
        pop    AR1                ;restore AR1
        popf   R0                 ;restore upper 32 bits of R0
        pop    R0                 ;restore lower 32 bits of R0
        pop    ST                 ;restore status register
        reti
;====================================================================;
; By placing the stack at the end of the users runtime code, the     ;
; maximum space is made available for applications.  Essentialy once ;
; used initialization code or data can be reclaimed after it is used.;
; However, use this configuration for debug purposes                 ;
;====================================================================;
          .start   "STACK",$        ; This is a reminder to put the stack
          .sect    "STACK"          ; stack in a safe place.  $ places
stack     .word     stack         ; section at the current assy address
;****************************************************;
; Install the XINT/RINT ISR handler directly into    ;
; the vector RAM location it will be used in         ;
;****************************************************;
             .start   "SP0VECT1",0x809FC5
             .start   "SP0VECT2",0x809FC6       
             .sect    "SP0VECT1"
              BR         XINT0         ; Go to routine RINT0
             .sect    "SP0VECT2"
              BR         RINT0        ; Go to routine XINT0                             
            .end