These forums are read only, please use our new forums here.

Main :: ToneCore Development Kit



Assembler directive DC (Define Constant) does not work
by turjakas on 2009-04-10 00:56:12

I've had a serious problem when programming the pedal - the DC directive that is

used to define constant data in the processor internal memory does not work.

When reading the data defined with DC in the memory, only random data is

returned. I've checked this by printing out the values read from the memory

to the debug read fields in the TCDDK pedal software.

Is the DC directive even supposed to work?

Also, I'm using the new 1.1 version of the pedal software

(as with the older version any program with DC definitions

did not work at all!).

Here is a sample program that causes the problem:

- the program just runs the processor initialization and copies the TestConstantN values to the debug registers

- the interrupt vectors have been omitted from the program

- the program is based on the Line6 stereo EQ example

                page    132,60
                include "..\Ioequ.inc"
                include "..\vectors4.inc"               
                list

;*********************
; X-memory allocations
;*********************
        org     x:$000
; Knob registers expect a value of 0x000000 thru 0x7FFFFF from the microcontroller
Knob_1                  ds  1       ; 00h
Knob_2                  ds  1       ; 01h
Knob_3                  ds  1       ; 02h
Knob_4                  ds  1       ; 03h
Knob_5                  ds  1       ; 04h
Knob_6                  ds  1       ; 05h

; Switch registers expect a value of 0,1, or 2 from the microcontroller
Switch_1                ds  1       ; 06h
Switch_2                ds  1       ; 07h

; FootSwitch registers expect a value of 0x000000 or 0x000001 from the microcontroller
FootSwitch_TopLayer     ds  1       ; 08h
FootSwitch_BottomLayer  ds  1       ; 09h

; LED registers are read by the micro and should be set to 0x000000 or 0x000001  (off and on)
LED_Red                 ds  1       ; 0ah
LED_Green               ds  1       ; 0bh

; RX and TX registers
LeftRx                  ds  1       ; 0ch   Left received sample
RightRx                 ds  1       ; 0dh   Right received sample
LeftTx                  ds  1       ; 0eh   Left sample to transmit
RightTx                 ds  1       ; 0fh   Right sample to transmit
SHI_StateMachine        ds  1       ; 10h   current state of the serial host interface
HostCommand             ds  1       ; 11h   current SHI command

; Debug registers
Debug_Write_to_DSP_1    ds  1       ; 12h   recieves data from the ToneCoreGUI application
Debug_Write_to_DSP_2    ds  1       ; 13h   recieves data from the ToneCoreGUI application
Debug_Write_to_DSP_3    ds  1       ; 14h   recieves data from the ToneCoreGUI application
Debug_Write_to_DSP_4    ds  1       ; 15h   recieves data from the ToneCoreGUI application
Debug_Read_from_DSP_1   ds  1       ; 16h   send data to the ToneCoreGUI application
Debug_Read_from_DSP_2   ds  1       ; 17h   send data to the ToneCoreGUI application
Debug_Read_from_DSP_3   ds  1       ; 18h   send data to the ToneCoreGUI application
Debug_Read_from_DSP_4   ds  1       ; 19h   send data to the ToneCoreGUI application

; Foot Latch states
FootLatch               ds  1       ; 20h
FootLatchMem            ds  1       ; 21h

; Test constants
TestConstant1           dc  $123456
TestConstant2           dc  $345678

;*********************
; Y-memory allocations
;*********************
        org     y:$000
TestConstant3
                              dc     0.020216079055843

;*****************************************************************************************************
; The main program starts here. Include your initialization procedures at the end of the START section
;*****************************************************************************************************
        org     p:$4E
START
        ori     #$03,mr                 ; mask interrupts
        movep   #$2D0063,X:M_PCTL       ; Set PLL Control Register: Fosc = 100 MHz = (100)(3 MHz)/3
        bset    #14,omr                 ; allow address attributes line to function independently
        movep   #>$000040,x:M_SAICR     ; 4x4 Synchronous mode (use TX frame and bit clks)
        movep   #$FCC304,x:M_TCCR                          
        movep       #$FCC304,x:M_RCCR                         
        movep   #$707d00,x:M_RCR                           
        movep   #$027D80,x:M_TCR                           
        movep   #>$000000,x:M_PDRC      ; Clear Port C data
        movep   #>$000BF8,x:M_PCRC      ; Set appropriate Port C GPIO pins for ESAI .
        movep   #>$000C7E,x:M_PRRC      ; Set pin direction of PORT C
        movep   #>$000000,x:M_PCRB      ; Set up Port B for output
        movep   #>$00000F,x:M_PRRB      ; Set up Port B for output
        movep   #>$000008,x:M_PDRB      ; bit 0 = In_EMPH, bit 1 = OUT_DE_EMPH, bit 2 = DIRECT_ON, bit 3 = FX_ON
        movep   #>$000003,x:M_RSMA      ; Enable first 2 time slots for receive.
        movep   #>$000000,x:M_RSMB      ;
        movep   #>$000003,x:M_TSMA      ; Enable first 2 time slots for transmit.
        movep   #>$000000,x:M_TSMB     
        movep   #>$000000,x:M_TX0       ; zero out transmitter 0
        ; ENABLE ESAI
        bset    #0,x:M_RCR              ; now enable RX0
        bset    #0,x:M_TCR              ; now enable TX0
          ; Setup Expansion Port A for SRAM...
        movep   #$2406B5,x:M_AAR0               
        movep   #$2003B1,x:M_AAR1
          ; Bus Control Register for SRAM...
        movep   #$0124A5,x:M_BCR        ;        0001 0010 0100 0110 0011
          ; Set up SHI (Serial Host Interface to the MCU)...
        movep   #>$003001,x:M_HCKR      ; Turn Data/Clk Line Filter to max, wide spike tolerance (100ns glitch)
        movep   #>$001189,x:M_HCSR      ; CPHA=1, CPOL=0 : => same as reset/power-on.
          ; Initialize registers
        move    #>$000000,x0
        move    x0,r0
        rep     #28
        move    x0,x:(r0)+              ; clear start of x:mem
        move    #>$400000,x0               ; Intialize the knob registers
        move    x0,x:Knob_1    
        move    x0,x:Knob_2    
        move    x0,x:Knob_3    
        move    x0,x:Knob_4    
        move    x0,x:Knob_5    
        move    x0,x:Knob_6    
        move    #>$000000,x0
        move    #$00ffff,m5             ; Use r5 for the MCU parameter updates.
        movep   x0,x:M_HTX              ; Assert HREQ* pin for the MCU.
          ; Initialize Peripheral Interrupt Priority Register for Audio Interrupts and SHI.
        movep   #$000007,x:M_IPRP       ; ESAI int's enabled and top Priority, SHI int's enabled and lowest Priority.
        andi    #$FC,mr                 ;enable all interrupt levels
        movep   #>$000002,x:M_PDRC      ; Take CODEC out of power down mode.

; -----------------------------------------
; Print out test data using debug registers
; -----------------------------------------

     move     x:TestConstant1,x0
     move     x0,x:Debug_Read_from_DSP_1 ; should print out $123456
     move     x:TestConstant2,x0
     move     x0,x:Debug_Read_from_DSP_2 ; should print out $345678
     move     y:TestConstant3,x0
     move     x0,x:Debug_Read_from_DSP_3

;------------------------------------------------------------
; Main loop
;------------------------------------------------------------
MainLoop
        wait
          ; Waiting for interruptions from ESAI and SHI
        jmp     MainLoop



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-13 18:40:39

I've seen this problem as well.

I think the DC directive works with the simulator, but NOT when running on the pedal . This bug is very inconvenient when you need to use any data tables (e.g. for FIR filter co-efficients, log volume controls).

Can someone from Line6 tell us what we need to do to get this fixed? Do we need to send a bug report to Freescale?

Dave



Re: Assembler directive DC (Define Constant) does not work
by LukeD on 2009-04-14 09:27:55

I just use the EQU directive.  That seems to do what you want.  I'm not sure what the DC directive is for.



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-14 19:27:06

I don't think the EQU directive can be used to allocate and initialize a memory location (this is what the DC directive is supposed to do).

Dave



Re: Assembler directive DC (Define Constant) does not work
by PsiKTrOn on 2009-04-16 11:46:03

Hi,

The DS and DC expression don't have a meaning in the DSP.

It's just compiler intructions to help the developer's job.

When you create a dc value, you only associate a name to a value. So when in your code you want to put the value, you put the name and the code becomes easier to read.

But this instruction will not appear in the final code that you will flash in your dsp.

If you want to create a constant value for your program you have to initialize it in the "initialization part". (When the knobs are set to zero).

I hope this will help you.



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-17 09:02:10

DS and DC directives *do* have "meaning in the DSP". They both allocate a memory location in physical  X or Y memory on the device. In the case of the DC directive, it should also initialize the memory location to the specified value. It's not just associating a name to a value.There's no instruction associated with DS and DC directives, but if you look at the memory map generated during assembly/linkage, your will see the memory location being allocated in X or Y memory. Look at the DC and DS directive descriptions in the Freescale DSP Assembler Reference manual (pg 98, 101) for more details.

DC doesn't work as it should when running on the real pedal.

Dave



Re: Assembler directive DC (Define Constant) does not work
by PsiKTrOn on 2009-04-17 14:39:41

Knob_1                  ds  1       ; 00h
Knob_2                  ds  1       ; 01h
Knob_3                  ds  1       ; 02h
Knob_4                  ds  1       ; 03h
Knob_5                  ds  1       ; 04h
Knob_6                  ds  1       ; 05h

When you write this, you just associate the name with an address. It's very similar to allocating but they are no action performed in the X and Y memory.

the dsp only execute the code writed after org p:$4E.

Where P means the program memory.

This is the only thing that is send to the dsp. So that's why your dc value does'nt work.

The line6 GUI only send data to the program memory. The other memories are unchanged.

That's why you receive only a random value and that's why they initialize the knob value and all the other parameters in the program code!!

Believe me, you will never use the dc command like you want.



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-18 10:53:54

From page 98 of the Freescale DSP Assembler Reference Manual:

"The DC directive allocates and initializes a word of memory for each <arg> argument.
<arg> may be a numeric constant, a single or multiple character string constant, a symbol,
or an expression. The DC directive may have one or more arguments separated by commas.
Multiple arguments are stored in successive address locations. If multiple arguments
are present, one or more of them can be null (two adjacent commas), in which case
the corresponding address location will be filled with zeros. If the DC directive is used in
L memory, the arguments will be evaluated and stored as long word quantities. Otherwise,
an error will occur if the evaluated argument value is too large to represent in a single
DSP word.


<label>, if present, will be assigned the value of the runtime location counter at the start
of the directive processing.

EXAMPLE:
TABLE DC 1426,253,$2662,'ABCD' "

Maybe the Line6 GUI only sends program memory code down, but if it doesn't handle DC directives properly then this should be stated somewhere in their documentation.

Dave



Re: Assembler directive DC (Define Constant) does not work
by PsiKTrOn on 2009-04-20 02:10:21

From page 67 of the Freescale DSP Assembler Reference Manual:

6.1 Introduction

This chapter describes the directives that are recognized by the Freescale DSP Assembler. The assembler directives are instructions to the assembler rather than instructions to be directly translated into object code. In addition, this chapter describes special characters that are considered significant to the assembler.

As you can see, the DC directive is not translated in code object. This directive is for the assembler. So it's just a help for the development process. I think the dc command has to be used for quick debbuging.

In conclusion, the dc directive has no meaning in the DSP and will never have a meaning in it.



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-20 13:16:44

So what does "The DC directive allocates and initializes a word of memory for each <arg> argument" mean then? What memory is being allocated and initialized? Memory on the machine where you assembled and linked your code? And "If the DC directive is used in L memory the arguments will be evaluated and stored as long word quantities." -  what is "L memory" referring to? Where will the arguments "be stored as long word quantities"?

How would one use the DC directive for "quick debugging"?

Dave



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-20 15:00:55

The following code works on the pedal (I defined this in a separate asm file in my project):


        SECTION P_DATA_MEMORY GLOBAL

        org     p:$3EE  ; a location past end of my program's memory

CONST_1 DC $AFAFAF
CONST_2 DC $121212
       
        ENDSEC

To verify in my application code:

         move p:CONST_1,x1
         move x1,x:Debug_Read_from_DSP_2
         move p:CONST_2,x1
         move x1,x:Debug_Read_from_DSP_3

So the problem is likely that X/Y memory info is not sent down to the device by the Tonecore GUI. But the DC directive does work as stated in the manual in this case.

Dave



Re: Assembler directive DC (Define Constant) does not work
by dlfowler on 2009-04-20 17:15:58

To the OP:

I think DC will work in P memory as follows:

Define something like this (with your constants) in a separate ".asm" file in your project (I used "pMem.asm"):

  SECTION P_DATA_MEMORY GLOBAL

        ; This section will be located after any absolute P sections (i.e. after  the "org p:$4E" section

        ; in "main.asm" in the stereo eq example).

        org     p: 


CONST_1   DC $AFAFAF
CONST_2   DC $121212
CONST_3   DC -0.5
      
        ENDSEC

Then in your application code to access these constants:

      ; Test
      move #CONST_2,r3
      move p:(r3)+,x1
      move x1,x:Debug_Read_from_DSP_1  ; will display $121212
      move p:(r3),x1
      move x1,x:Debug_Read_from_DSP_2 ; will display $C00000

I'm pretty sure I read somewhere in the assembler or linker manual that non-absolute sections (i.e . org p:) will be placed after absolute sections - I can't find it though. It looks like that's the case in my memory map file anyway. Using DC in P memory does mean you will have less space for your program code though.

Dave



Re: Assembler directive DC (Define Constant) does not work
by clangen on 2009-07-18 03:11:26

> the dsp only execute the code writed after org p:$4E.

> Where P means the program memory.

> This is the only thing that is send to the dsp. So that's why your dc value does'nt work.

> The line6 GUI only send data to the program memory. The other memories are unchanged.

> That's why you receive only a random value and that's why they initialize the knob value and all the other parameters in the program code!!

Is that true? I couldn't find elsewehere in the manual that only te p-memory is written by the GUI. Could someone point me to this?

A workaround that could be to initialize the memory by initialization in the program. That makes the application code big and ugly but helps. I'm currentlx working on this after experiencing that ANY dc assembly directive crashed my application.

Best ragards

Crhistian



Re: Assembler directive DC (Define Constant) does not work
by clangen on 2009-07-19 02:41:54

I explored the bahaviour of the DC (Define Constant) woes and can summarizre the following 'under the hood' details.

1.) The DSP56364 bootstrap mode is adjusted to Mode $D (see Table 4.1 on page 53 in the DSP56364 User Manual). In the mode the bootloader programs up to 1280 24bit words to the program memory. The first word indicates the application code size (in 24bit words), the second the start adress where this code is written to. The is NO write of x or y data RAM done by this bootstrap loader. For that reson NO defines for data RAM constants (coefficient tables e.t.c.) are written to data memory. If you intend to do this you have to modify the DSP code in that respect that it first starts a piece cf code that does the data memory writing, next starts the aplication code and runs it. This 'overlay' technique is somewhat advanced but can be done.

2.) If you take a closer look to the examles you see that none of them use DC (Define Constant) for data RAM. My workaround is to define the data variables like this

AlphaBase     equ     $020         ; (L) AttackTime, Rectifier, 16*48, $000020..$000002F

next allocate a data field in memory

        org        x:AlphaBase
AlphaData                ds    16

all this is not generating DSP code yet but make the code better readable.

The insitialization of the tables is a little bit ugly but works

;*************************************************************************
; Initialize Tables       
;*************************************************************************
; Alpha
        move    #>0.9999040636,x0
        move    x0,l:AlphaBase

        move    #>0.4102564031,x0
        move    x0,l:AlphaBase+1
       
        move    #>0.1291617907,x0
        move    x0,l:AlphaBase+2

        move    #>0.03445821577,x0
        move    x0,l:AlphaBase+3

...

The drawback of this method is that is blows up the DSP code significantly by writing the data tables explicitely. The good news is that the 56364 can eat up to 1.25kWords code

If you want to bootstrap a larger application than the TwoBandStereoEQ (this is the application code the ToneCore development kit is shipped with) you have to modify the MCU application according to the TCDDK Users Guide. I did this using the Metrowerks compiler (I had to change the *.map file name in the /bin folder firstly before the IDE could build the project). The linker defines 3843 bytes for DSP code (= 1281 Words) so the maximum program RAM size for the DSP56364 could be used in theory.

If you do not change the MCU program it will download 15F words (= 351 in decimal) only, so a part of the application is run on the DSP only, so the bahaviour is unpredictable.

Following the instruction on pages 37 to 42 in the TCDDK Users Guide explains how to change the MCU code. The bootloader mode described on page 36 explains how to flash the MCU.

This is exacly what I did, unfortunately the problem is not solved completely. The bootstrap loader behaves as if only a part of the application is downloaded to the DSP. A good check for this is to send a 'knob' variable to a Debug_Read_from_DSP variable to indicate if the code is alive at this point, like this

        move    x:Knob_1,b1

        nop 
        move    b1,x:Debug_Read_from_DSP_1   

if you connect the ToneCore pedal to by the USB cable co van see the changing know value. If there is no reaction the corresponding part has not been loaded to the DSP.

The funny thing is after reloading the TwoBandStereoEQ all knobs are 'activated' again. When I uploaded my 1.25kWord application next I can find it in the DSP completely, but it doesn't seem to be bootstrapped by the MCU since after powering up the device it has 'forgotten' half of its features.

I hope I could solve the problem regarding the DC(define constant) issue. I will post the corresponding code size issue seperately.

Christian




The information above may not be current, and you should direct questions to the current forum or review the manual.