如何将变量放入访问组 - PIC 18 MPASM 链接器脚本

发布于 2024-11-28 16:49:38 字数 1062 浏览 1 评论 0原文

我有一个链接器脚本,它启动时

    INCLUDE 18f14K50_g.lkr

我希望我的中断服务变量进入 ACCESS 库。 (我的程序目前很小,全部都可以,但也许将来......)。结果

    SECTION     NAME=VarsModemISR   RAM=accessram

是:

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

检查包含的文件,我相信它是。要么我在扩展模式下工作,而“gpre”就是。我可以使用#IFDEF 来检查,我尝试过。结果,它尝试使用“accessram”而不是“gpre”。

也许如果我尝试通过复制包含文件中的行来显式定义访问库:

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

这会导致错误

MPLINK 4.39, Linker
Device Database Version 1.1
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - duplicate definition of memory 'accessram' 
Errors    : 1

,这让我感到困惑。根据汇编器/链接器文档,我将 SECTION 与 RAM 选项一起使用,其中 RAM 先前已使用 ACCESSBANK、SHAREBANK 或 DATABANK 声明。它应该有效。

谢谢 ——理查德

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 Microchip 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我闹别瞎闹 2024-12-05 16:49:38

确实不需要更改链接描述文件,使用默认链接描述文件!

在 PIC18 MCPU 下,访问的文件寄存器随时可用。
只需在名为 ACCESSBANK 的适当内存数据库中声明变量,该数据库从 0x00 地址开始,到 0x60 地址结束。

如果您使用 MPLAB,则声明:

_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
;...

链接器应自动设置文件寄存器地址的代码指令中的“a”位,这些地址在 ACCESSBANK 中声明。

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.

一身软味 2024-12-05 16:49:38

我正在使用 UDATA_ACS 来声明我想要访问的变量,因此在 modem.asm 中我有

; 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
...

我当前的链接器脚本使用提供的脚本,但定义了我的段。我注意到脚本中只定义了一个程序页,这与 PIC16 不同。不再有 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

生成的映射包含我期望的映射:

按预期硬编码位置:

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

可移动位置打包在:

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

EEPROM 位于正确的位置

     CodeConfigEEPROM       code   0xf00000    program   0x000044

以及 ACCESSRAM 和 GP0 中的变量

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

还有更多问题需要解决,但它们可能在其他帖子中。我注意到 CodeWaveTable 占用 64 个字节,因此它的包装并不紧密。解决方案 - 使用 CODE_PACK,现在它是 32 字节。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文