• AVR Freaks

Hot!Array too large for memory?

Author
Number_two
Starting Member
  • Total Posts : 35
  • Reward points : 0
  • Joined: 2015/01/24 20:18:41
  • Location: 0
  • Status: offline
2019/11/11 06:44:37 (permalink)
0

Array too large for memory?

I'm using a PIC16LF18345 with relocatable assembly and I'm having issues with not being able to find space for a couple of 21 byte arrays.

The weird thing is, I have code that does work on this chip and has WAY more bytes reserved for variables AND two 21 byte arrays reserved and everything is fine.

I'm not sure if the linker is just doing something odd and placing them in a weird order? The only solution I can think of is to switch to absolute and define the memory locations myself. Anybody know of a way around this? I'd like to stick with relocatable if at all possible.
#1

6 Replies Related Threads

    pcbbc
    Super Member
    • Total Posts : 1388
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Array too large for memory? 2019/11/11 07:31:16 (permalink)
    +2 (2)
    The problem is on line #42 of your source code which you haven't shown us.
    If you cannot post your actual code, post a minimum example which clearly demonstrates the problem.
    #2
    1and0
    Access is Denied
    • Total Posts : 10005
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Array too large for memory? 2019/11/11 08:04:46 (permalink)
    0
    Post ALL of your UDATA sections.
    #3
    Number_two
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2015/01/24 20:18:41
    • Location: 0
    • Status: offline
    Re: Array too large for memory? 2019/11/11 16:48:01 (permalink)
    0
    Sorry, I didn't have my computer with me. But, I did figure it out...sort of. The error was:
    Error - section 'GPR_VAR' can not fit the section. Section 'GPR_VAR' length=0x0000005c

    So I changed the name of GPR_VAR in one of the files to GPR_X and it worked.
     
    I'm still not sure how it allocates memory (I'm used to programming in C). Is there a byte limit per block that can't be exceeded? Apparently it's something like 0x50 ?
    #4
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Array too large for memory? 2019/11/11 17:08:47 (permalink)
    0
    What linker script are you using?
    The standard one that comes with MPLABX (16f18345_g.lkr) does not contain a section named "GPR_VAR")
    If you put all your arrays into the section named "LINEAR0" there should be no problem.
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    Number_two
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2015/01/24 20:18:41
    • Location: 0
    • Status: offline
    Re: Array too large for memory? 2019/11/11 17:26:45 (permalink)
    0
    I'm not sure.
     
    It says this when I build:
    "/opt/microchip/mplabx/v5.25/mpasmx/mplink" -p16lf18345 -w -m"dist/default/production/systems.X.production.map" -z__MPLAB_BUILD=1 -odist/default/production/systems.X.production.cof build/default/production/main.o build/default/production/device_config.o build/default/production/memory.o build/default/production/spi.o build/default/production/tmr2.o build/default/production/eusart.o build/default/production/interrupt.o build/default/production/radio.o 
    MPLINK 5.09, LINKER
    Device Database Version 1.47

     
    I used GPR_VAR because that's what it has when you use the default generic .asm file. LoL: LoL
    Also, my UDATA section looks like this:
    GPR_VAR    UDATA 
    RX_FIFO    RES 24
    FIFO_SIZE  RES 1

    #6
    1and0
    Access is Denied
    • Total Posts : 10005
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Array too large for memory? 2019/11/11 17:28:47 (permalink)
    0
    I think GPR_VAR is a regular section name from the user, and a plain UDATA section can have a maximum of one bank of GPR which is 80 (0x50) bytes.
     
    As Ric said, a LINEAR0 section can have up to the maximum available RAM minus the 16-byte shared RAM. Variables in the linear section will be accessed via linear addressing.
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5