PIC18F8527 Array Limit


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2009
    Posts
    6

    Default PIC18F8527 Array Limit

    According to the PBP manual, PIC18Xxxxx device variable arrays are only limited by available memory. I have verified there is lots of available memory, but the line:

    AIAvgReg var word[128]

    gets me this error

    ERROR: Unable to fit variable AIAvgReg

    Reducing the number of elements to 127 works ok. Even if the limit was one RAM bank, as in older PICS, the 128 Words should still fit in one bank.

    Any idea what is wrong?

    PBP 2.60A, PBPL

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jtowich View Post
    Any idea what is wrong?

    PBP 2.60A, PBPL
    No, but it does compile correctly here for
    Code:
    AIAvgReg var word[1500]
    , even when using pbpl.

    So, either, you are using too many other variables, or possibly, you are compiling for the wrong chip. Or, maybe mpasm version issue?

    Walter
    http://www.scalerobotics.com

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    What else do you have in ways of variables? I tried it here and it compiles just fine, even with the array declared as 1900 words. Are you sure you're compiling for the 18F8527 and not a device with less RAM?

    /Henrik.

    EDIT: Ha, double post there Walter, pretty identical as well :-)

  4. #4
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Thanks for the quick response

    I am definitely have the 18F8527 selected. I tried an array of 1000 words and it didn't work. However, it works fine if I try 10 arrays of 127 words, so lack of memory is not an issue. Just doesn't like anything over 255 bytes in an array.

    I'll keep looking.

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    If you open up your xxxx.lst file, you can see where your assembler thinks the ram start and end locations are. For some reason, this sounds buggered. It also will show which MPASM version you are using, and which processor includes you are using.

    Here's what mine looked like. You can compare it to yours and see if there are differences in RAM locations.
    Code:
    MPASM  5.38                      UNTITLED.ASM   1-21-2011  10:05:20         PAGE  1
    
    
    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE
    
                          00001 
                          00002 ; PICBASIC PRO(TM) Compiler 2.60LA, (c) 1998, 2009 microEngineering Labs, Inc. All Rights Reserved. 
      00000001            00003 _USED                   EQU     1
                          00004 
                          00005         INCLUDE "C:\PBP\18F8527.INC"
                          00001 ;****************************************************************
                          00002 ;*  18F8527.INC                                                 *
                          00003 ;*                                                              *
                          00004 ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
                          00005 ;*  Notice    : Copyright (c) 2008 microEngineering Labs, Inc.  *
                          00006 ;*              All Rights Reserved                             *
                          00007 ;*  Date      : 09/15/08                                        *
                          00008 ;*  Version   : 2.60                                            *
                          00009 ;*  Notes     :                                                 *
                          00010 ;****************************************************************
                          00017         LIST
                          00018         LIST p = 18F8527, r = dec, w = -311, w = -230, f = inhx32
                          00019         INCLUDE "P18F8527.INC"  ; MPASM  Header
                          00001         LIST
                          00002 
                          00003 ;==========================================================================
                          00004 ;  MPASM PIC18F8527 processor include
                          00005 ; 
                          00006 ;  (c) Copyright 1999-2010 Microchip Technology, All rights reserved
                          00007 ;==========================================================================
                          00008 
                          02400         LIST
    300000 32FF           00020         __CONFIG    _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    300002 F31F           00021         __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    300006 FF8B           00022         __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_BB2K_4L & _XINST_OFF_4L
                          00025         LIST
      00F00000            00026 EEPROM_START    EQU     0F00000h
      00000040            00027 BLOCK_SIZE      EQU     64
                          00006 
      00000000            00007 RAM_START                       EQU     00000h
      00000F5F            00008 RAM_END                         EQU     00F5Fh
      00000010            00009 RAM_BANKS                       EQU     00010h
      00000060            00010 BANK0_START                     EQU     00060h
      000000FF            00011 BANK0_END                       EQU     000FFh
      00000100            00012 BANK1_START                     EQU     00100h
      000001FF            00013 BANK1_END                       EQU     001FFh
      00000200            00014 BANK2_START                     EQU     00200h
      000002FF            00015 BANK2_END                       EQU     002FFh
      00000300            00016 BANK3_START                     EQU     00300h
      000003FF            00017 BANK3_END                       EQU     003FFh
      00000400            00018 BANK4_START                     EQU     00400h
      000004FF            00019 BANK4_END                       EQU     004FFh
      00000500            00020 BANK5_START                     EQU     00500h
      000005FF            00021 BANK5_END                       EQU     005FFh
      00000600            00022 BANK6_START                     EQU     00600h
      000006FF            00023 BANK6_END                       EQU     006FFh
      00000700            00024 BANK7_START                     EQU     00700h
      000007FF            00025 BANK7_END                       EQU     007FFh
    MPASM  5.38                      UNTITLED.ASM   1-21-2011  10:05:20         PAGE  2
    
    
    LOC  OBJECT CODE     LINE SOURCE TEXT
      VALUE
    
      00000800            00026 BANK8_START                     EQU     00800h
      000008FF            00027 BANK8_END                       EQU     008FFh
      00000900            00028 BANK9_START                     EQU     00900h
      000009FF            00029 BANK9_END                       EQU     009FFh
      00000A00            00030 BANK10_START                    EQU     00A00h
      00000AFF            00031 BANK10_END                      EQU     00AFFh
      00000B00            00032 BANK11_START                    EQU     00B00h
      00000BFF            00033 BANK11_END                      EQU     00BFFh
      00000C00            00034 BANK12_START                    EQU     00C00h
      00000CFF            00035 BANK12_END                      EQU     00CFFh
      00000D00            00036 BANK13_START                    EQU     00D00h
      00000DFF            00037 BANK13_END                      EQU     00DFFh
      00000E00            00038 BANK14_START                    EQU     00E00h
      00000EFF            00039 BANK14_END                      EQU     00EFFh
      00000F00            00040 BANK15_START                    EQU     00F00h
      00000F5F            00041 BANK15_END                      EQU     00F5Fh
      00000000            00042 BANKA_START                     EQU     00000h
      0000005F            00043 BANKA_END                       EQU     0005Fh
    http://www.scalerobotics.com

  6. #6
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    My lst shows the same memory locations and processor. Strange.
    Code:
                          00001 
                          00002 ; PICBASIC PRO(TM) Compiler 2.60LA, (c) 1998, 2009 microEngineering Labs, Inc. All Rights Reserved. 
      00000001            00003 _USED                   EQU     1
                          00004 
                          00005         INCLUDE "C:\PBP\18F8527.INC"
                          00001 ;****************************************************************
                          00002 ;*  18F8527.INC                                                 *
                          00003 ;*                                                              *
                          00004 ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
                          00005 ;*  Notice    : Copyright (c) 2008 microEngineering Labs, Inc.  *
                          00006 ;*              All Rights Reserved                             *
                          00007 ;*  Date      : 09/15/08                                        *
                          00008 ;*  Version   : 2.60                                            *
                          00009 ;*  Notes     :                                                 *
                          00010 ;****************************************************************
                          00017         LIST
                          00018         LIST p = 18F8527, r = dec, w = -311, w = -230, f = inhx32
                          00019         INCLUDE "P18F8527.INC"  ; MPASM  Header
                          00001         LIST
                          00002 
                          00003 ;==========================================================================
                          00004 ;  $Id: P18F8527.INC,v 1.2.2.3 2005/10/18 21:44:56 curtiss Exp $
                          00005 ;  MPASM PIC18F8527 processor include
                          00006 ; 
                          00007 ;  (c) Copyright 1999-2005 Microchip Technology, All rights reserved
                          00008 ;==========================================================================
    
    
    
      00000000            00029 RAM_START                       EQU     00000h
      00000F5F            00030 RAM_END                           EQU     00F5Fh
      00000010            00031 RAM_BANKS                       EQU     00010h
      00000060            00032 BANK0_START                    EQU     00060h
      000000FF            00033 BANK0_END                       EQU     000FFh
      00000100            00034 BANK1_START                    EQU     00100h
      000001FF            00035 BANK1_END                       EQU     001FFh
      00000200            00036 BANK2_START                    EQU     00200h
      000002FF            00037 BANK2_END                       EQU     002FFh
      00000300            00038 BANK3_START                    EQU     00300h
      000003FF            00039 BANK3_END                       EQU     003FFh
      00000400            00040 BANK4_START                    EQU     00400h
      000004FF            00041 BANK4_END                       EQU     004FFh
      00000500            00042 BANK5_START                    EQU     00500h
      000005FF            00043 BANK5_END                       EQU     005FFh
      00000600            00044 BANK6_START                    EQU     00600h
      000006FF            00045 BANK6_END                       EQU     006FFh
      00000700            00046 BANK7_START                    EQU     00700h
      000007FF            00047 BANK7_END                       EQU     007FFh
      00000800            00048 BANK8_START                    EQU     00800h
      000008FF            00049 BANK8_END                       EQU     008FFh
      00000900            00050 BANK9_START                    EQU     00900h
      000009FF            00051 BANK9_END                       EQU     009FFh
      00000A00            00052 BANK10_START                   EQU     00A00h
      00000AFF            00053 BANK10_END                      EQU     00AFFh
      00000B00            00054 BANK11_START                   EQU     00B00h
      00000BFF            00055 BANK11_END                      EQU     00BFFh
      00000C00            00056 BANK12_START                   EQU     00C00h
      00000CFF            00057 BANK12_END                      EQU     00CFFh
      00000D00            00058 BANK13_START                   EQU     00D00h
      00000DFF            00059 BANK13_END                      EQU     00DFFh
      00000E00            00060 BANK14_START                    EQU     00E00h
      00000EFF            00061 BANK14_END                      EQU     00EFFh
      00000F00            00062 BANK15_START                    EQU     00F00h
      00000F5F            00063 BANK15_END                      EQU     00F5Fh
      00000000            00064 BANKA_START                     EQU     00000h
      0000005F            00065 BANKA_END                       EQU     0005Fh
                                00066 
      00000000            00067 FLAGS                           EQU     RAM_START + 000h
      00000001            00068 GOP                             EQU     RAM_START + 001h
    MPASM  5.03                      PCB6AI~1.ASM   1-21-2011  12:16:16         PAGE  3
    Last edited by ScaleRobotics; - 21st January 2011 at 20:02.

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Just a guess, but I suspect an MPLAB upgrade will fix your problem.

    MPASM 5.03
    is pretty old....

    I suspect that whatever is wrong, is fixed in one of the many newer versions.
    http://www.scalerobotics.com

  8. #8
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    upgraded to MPASM 5.39, no change.

    I'll try reloading all the software when I get a chance.

  9. #9
    Join Date
    Jul 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I found the problem.

    I am using assembly interrupts that reserve a location in each bank for the wsave register. This effectively limits an array size to 255 bytes since the array can't cross this reserved register.

    Luckily this processor has a special stack that will store the W, STATUS, and BSR registers automatically and then automatically restore them if a "fast" retfie command is used. This removes the requirement to reserve a memory location in each bank for the wsave register. Using this method works as advertised. This will only work if high priority interrupts are not used, which was the case in my code.

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    On 18F types you can force your context saving vars to be placed in access ram so there's no need to put them in more than 1 place.

    wsave var byte BANKA SYSTEM ' location for WREG
    ssave var byte BANKA SYSTEM ' location for STATUS register
    bsave var byte BANKA SYSTEM ' location for BSR register
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jtowich View Post
    I found the problem.

    I am using assembly interrupts that reserve a location in each bank for the wsave register. This effectively limits an array size to 255 bytes since the array can't cross this reserved register.
    You might want to use DT_INTS, it makes it pretty easy to use interrupts, and doesn't cause the problems you are seeing, whether using asm or pbp type interrupts.

    http://darreltaylor.com/DT_INTS-18/home.html
    http://www.scalerobotics.com

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts