PICmicro & dsPIC >> PIC F.A.Q. (Frequently Asked Questions)

Pages: 1
Andrew LModerator
Microchip staff
*****

Reged: Feb 19 2006
Posts: 74
Loc: Brisbane, Australia
DSPICC STD 9.60 Code Offset
      #27912 - Tue Jun 05 2007 09:28 PM

Unlike the other PIC micro compilers the DSPICC STD 9.60 unfortunately has no code offset driver option. However one emulate the behaviour of a code offset option by offseting those psects which would be affected. A psect can be linked at a specific address, contiguously after a psect linked at a specific address or within a linker class. Those psects linked within a class can be offset in ROM by reserving the first 'offset' bytes using the --ROM driver option. The remaining psects can be offset by instructing the linker using the -L driver option.

Consider the following example output from the driver when it invokes the linker without a code offset. This output can be reproduced using the -v driver option for verbose output.
    hlink --edf=/hitech/opt/dspicc/9.50/dat/eng_msgs.txt -h+test.sym -z -Q30F6014
-ol.obj -M/tmp/cgtKa3OS1 -ver=dsPICC#V9.60 -ACODE=0100h-0FFFFh,010000h-017FFFh
-ANEARCODE=0100h-0FFFFh -AXDATA=0800h-027FFh -AYDATA=01800h-027FFh
-ACONFIG=01F00000h-01F0001Ch -AVECTORS=00h-07Fh -AALTVECTOR=080h-0FFh
-preset_vec=0h,vectors=4h,altvectors=80h -pconfig=CONFIG -pconst=200h,strings
-pinit=CODE -pend_init=init -ppowerup=CODE -pidata=NEARCODE -pyidata=NEARCODE
-pbss=0800h,bitbss,nvram,nvbit,data,stack
-pybss=01800h,ybitbss,ydata,ynvram,ynvbit -pheap=-02800h
-pmconst=08100h,mstrings -peeprom=07FF000h -DCODE=2 -DNEARCODE=2 -DVECTORS=2
-DALTVECTOR=2 /tmp/cgtI5kMpi.obj test.obj
/hitech/opt/dspicc/9.50/lib/dspicc-sc.lib
If we required a code offset of 100h then we'd recompile with the following additional options to the driver:
    --ROM=default,-0-100
and
    -L-preset_vec=100h,vectors=104h,altvectors=180h
and
    -L-pconst=400h,strings
and
    -L-pmconst=08200h,mstrings
Note:
  1. The constant psects from both RAM and ROM are included because the RAM address space from 8000h is mapped directly into the rom space using the PSV mechanism.
  2. Due to the differences in addressing modes employed by the compiler between the RAM and ROM constant psects the offset applied to the ROM psects (i.e. const and strings) needs to be twice as much as for the other psects.
  3. Constant data is always linked low in memory within the first PSV page. Therefore any code offset applied will reduce the maximum amount of constant data available to the program.

Using this technique you can also be selective about which of the above psects you'd like to apply an offset to.

--------------------
Andrew Lanham,
Microchip Technology


Post Extras: Print Post   Remind Me!   Notify Moderator  
chrisdude
stranger


Reged: Aug 02 2007
Posts: 13
Re: DSPICC STD 9.60 Code Offset [Re: Andrew L]
      #29092 - Tue Aug 07 2007 02:37 PM

I need to offset my dsPICC application by C02h (and put a small number at C00h). I tried what you outlined but it tells me -->

Error[493] : origin of psect "vectors" multiply defined
Error[493] : origin of psect "altvectors" multiply defined

What are the -L lines doing?

Thanks!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Andrew LModerator
Microchip staff
*****

Reged: Feb 19 2006
Posts: 74
Loc: Brisbane, Australia
Re: DSPICC STD 9.60 Code Offset [Re: chrisdude]
      #29094 - Tue Aug 07 2007 05:29 PM

The -L option instructs the driver to pass on what follows in the option's argument to the linker. Section 2.4.8 of the manual has a great deal more detail on this option. In the above the linker is passed -p options (see section 5.7.20 of the manual) to link the named psects at given locations.

The error messages you're getting indicate that the linker is being instructed to link the psects "vectors" and "altvectors" at more than one origin (i.e starting link address). Curious, could you perhaps reproduce the command-line invocation of the compiler and the resulting verbose output? If you're using an IDE such MPLAB then a cut'n'paste of the output window (or equivalent) would be helpful.

--------------------
Andrew Lanham,
Microchip Technology


Post Extras: Print Post   Remind Me!   Notify Moderator  
chrisdude
stranger


Reged: Aug 02 2007
Posts: 13
Re: DSPICC STD 9.60 Code Offset [Re: Andrew L]
      #29132 - Thu Aug 09 2007 11:09 AM

I suppose the difficulty I'm having is integrating the compiler with the MPLAB IDE.

I get this from the build output -->

Executing: "C:\Program Files\HI-TECH Software\DSPICC\std\9.60\bin\dspicc.exe" -C -E"traps.cce" "traps.c" -O"traps.obj" --WARN=-3 --DEBUGGER=ICD2 -G -Q --IDE=MPLAB --chip=33FJ256GP710
Executing: "C:\Program Files\HI-TECH Software\DSPICC\std\9.60\bin\dspicc.exe" -E"RTC_LED_ADC.lde" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\advolts.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\delay.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\hexdec.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\init_ADC.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\init_DMAC0.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\init_timer1.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\isr_ADC.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\isr_DMAC0.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\isr_timer1.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\lcd.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\main_rtc.obj" "C:\Projects\dspic\dsPIC33F Demo for Explorer 16 Board\traps.obj" -M"RTC_LED_ADC.map" --SUMMARY=default,psect -O"RTC_LED_ADC.cof" -O"RTC_LED_ADC.hex" --WARN=-3 --ROM=def
ault,-0-C02 -L-preset_vec=100h,vectors=104h,altvectors=180h -L-pconst=D00h,strings --DEBUGGER=ICD2 -G -Q --IDE=MPLAB --chip=33FJ256GP710
Error[493] : origin of psect "vectors" multiply defined
Error[493] : origin of psect "altvectors" multiply defined
BUILD FAILED: Thu Aug 09 10:04:02 2007

I have those prescribed options in the dsPICC linker "Use Alternate Settings" dialog. When I alternatively put them in the dsPICC compiler settings they appear to be ignored (app is not offset when compiled).

I'm trying to offset the hex file by 0xC02.

Thanks!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Andrew LModerator
Microchip staff
*****

Reged: Feb 19 2006
Posts: 74
Loc: Brisbane, Australia
Re: DSPICC STD 9.60 Code Offset [Re: chrisdude]
      #29189 - Mon Aug 13 2007 07:31 PM

I've been able to reproduce these errors in MPLAB with a very simple test program. After some fiddling-around I think I may have a solution for you. Consider the default invocation of the linker by the driver.

hlink.exe "--edf=C:\Program Files\HI-TECH\Software\DSPICC\std\9.60\dat\en_msgs.txt"
-h+test.sym -z -Q33FJ256GP710 -ol.obj -Mtest.map -E1 -ver=dsPICC#V9.60
-ACODE=0200h-0FFFFh,010000h-01FFFFh,020000h-02ABFFh -ANEARCODE=0200h-0FFFFh
-AXDATA=0851h-07FFFh -ANEARXDATA=0851h-01FFFh -AYDATA=04800h-07FFFh
-ACONFIG=01F00000h-01F00020h -AVECTORS=06h-0FFh -AALTVECTOR=0100h-01FFh
-AMCONST=08200h-0FFFFh -preset_vec=0h -pvectors=VECTORS -paltvectors=ALTVECTOR
-pconfig=CONFIG -pconst=0400h,strings -ptext=CODE -pnearidata=NEARCODE
-pnearyidata=NEARCODE -pidata=NEARCODE -pyidata=NEARCODE -pinit=CODE
-pend_init=init -ppowerup=CODE -pybss=YDATA,ybitbss,ydata,ynvram,ynvbit
-pnearbss=NEARXDATA,nearbitbss,nearnvram,nearnvbit,neardata -pbss=XDATA
-pbitbss=XDATA -pnvram=XDATA -pnvbit=XDATA -pdata=XDATA -pheap=-08000h
-pmconst=MCONST,mstrings -DCODE=2 -DNEARCODE=2 -DVECTORS=2 -DALTVECTOR=2
C:\DOCUME~1\hitech\LOCALS~1\Temp\sbg.obj main.obj
"C:\Program Files\HI-TECH Software\DSPICC\std\9.60\lib\dspicc-sc.lib"


You'll observe that the linker options are somewhat different from those in the original posting.
None-the-less the same principle still applies. May I suggest the following additional options
to provide your desired code offset of 0xC02. Note that these options assume an offset within
the program memory address space.


--rom=default,-0-c01

Reserves the first 0xC02 words in program memory.

-L-preset_vec=c02h

Positions the reset vector at the beginning of the new code offset.

-L-AALTVECTOR=0d02h-0e01h -L-AVECTORS=0c08h-0d01h

The psects which contain the interrupt vectors are in this instance linked using these linker classes.
However they are unaffected by the --rom option and must be given explicit ranges to reflect the new
offset.

-L-pconst=01c04h,strings

Positions the constant data within the first PSV page to reflect the new code offset.

-L-AMCONST=08e02h-0FFFFh

Positions the linking of the const objects in RAM to reflect the new offset imposed on the actual
const data in program memory.

FYI: We are currently working on a "Patch-Level" release of the DSPICC compiler (i.e. v9.60PL1) which will
include a driver code-offset option. This will be followed by a new release of the compiler. Both
releases will occur within the next 2-3 months.

--------------------
Andrew Lanham,
Microchip Technology


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 5 anonymous users are browsing this forum.

Moderator:  Andrew L 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is enabled
      UBBCode is enabled

Rating:
Topic views: 8847

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5