开发者

How to place variables in the access bank - PIC 18 MPASM linker script

I have a linker script which starts

    INCLUDE 18f14K50_g.lkr

I want my interrupt service variables to go into the ACCESS bank. (My program's so small at the moment the whole lot can, but maybe in future...). So

    SECTION     NAME=VarsModemISR   RAM=accessram

which results in:

MPLINK 4.39, Linker
Device Database Version 1.1
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - section 'VarsModemISR' has a memory 'accessram' which is not defined in the linker command file.
Errors    : 1

Examining the included file I believe it is. Either that or I'm working in extended mode and "gpre" is. I can use an #IFDEF to check, which I tried. The result, it was trying to use "accessram" not "gpre".

Maybe if I try defining the access bank explicitly by copying the line from the include file:

ACCESSBANK NAME=accessram  START=0x0               END=0x5F
SECTION     NAME=VarsModemISR   RAM=accessram

This results in the error

MPLINK 4.39, Linker
Device Database Version 1.1
Copyright (c) 1998-2011 Microchi开发者_开发问答p Technology Inc.
Error - duplicate definition of memory 'accessram' 
Errors    : 1

Which has me confused. According to the Assembler/Linker documentation I use SECTION with the RAM option, where RAM has previously been declared using ACCESSBANK, SHAREBANK or DATABANK. It should work.

Thanks - Richard


There is really no need to change linker script, use default one!

Accessed file registers are available at any moment under PIC18 MCPUs. Just declare variables in appropriate memory databank named ACCESSBANK which start at 0x00 and end at 0x60 address.

If you are using MPLAB than declare:

_Shared        udata_acs        0        ;Shared memory file registers
IntReg1        res              1
IntReg2        res              1
;...

_UpperBank0    udata            060h     ;Banked file memory registers
RegA           res              1
;...

_Bank1         udata            0100h    ;Banked file memory registers
N              res              1
;...

Linker should automatically set the 'a' bit in code instruction for file register addresses, which are declared in ACCESSBANK.


I am using UDATA_ACS to declare the variables I want in access, so in modem.asm I have

; Variables for the interrupt handler  - Access RAM
VarsModemISR    UDATA_ACS

wave_index          res 1     ; Index into the wave table for current sample
sample_period       res 1     ; Sample period in use, TMR0 ticks
sample_count        res 1     ; Amount of samples output since last bit boundary
fsrtmpl             res 1     ; Temporary store for FSR
fsrtmph             res 1     ; Temporary store for FSR

; Variables for the modem code  - GPR0, non-Access
VarsModem       UDATA

flag                res 1     ; Counter for transmitting AX25 flags
bit                 res 1     ; Bit counter when transmitting a character
ch                  res 1     ; Current character being transmitted
...

My current linker script uses the supplied script, but defines my segments. I note that there's only one program page defined in the script, unlike on the PIC16s. No more PAGESEL?

INCLUDE 18f14K50_g.lkr

SECTION     NAME=CodeModemISR   ROM=page
SECTION     NAME=CodeModem      ROM=page
SECTION     NAME=CodeWaveTable  ROM=page
SECTION     NAME=CodeEepromUtil ROM=page
SECTION     NAME=VarsModem      RAM=gpr0
SECTION     NAME=VarsGPSState   RAM=gpr0
SECTION     NAME=CodeConfigEEPROM   ROM=eedata

The resulting map contains the mappings I expect:

Hard coded locations as expected:

 HighInterruptVector       code   0x000008    program   0x000004
 LowInterruptVector       code   0x000018    program   0x000002

Movable locations packed in:

         CodeModemISR       code   0x00001a    program   0x000028
            CodeModem       code   0x000042    program   0x0000fe
        CodeWaveTable       code   0x000140    program   0x000040
             CodeMain       code   0x000180    program   0x000054

EEPROM in the right place

     CodeConfigEEPROM       code   0xf00000    program   0x000044

And variables in ACCESSRAM and GP0

         VarsModemISR      udata   0x000000       data   0x000005
            VarsModem      udata   0x000060       data   0x000027
         VarsGPSState      udata   0x000087       data   0x00000e

There are more problems to solve, but they may be in other posts. I note that CodeWaveTable is taking 64 bytes so it's not closely packed. Solution - use CODE_PACK and now it's 32 bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜