Are my variable counts too high?

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2017

    Post Are my variable counts too high?

    Hello everyone,

    My question is if using over 5K bytes as multiple arrays, variables and cons within a PIC18F67K40 would cause PBP not to be able to fit more.
    This PIC has a capacity of 128K bytes available.

    I have mulple arrays that vary in size such as examples:

    Array1 [540] var byte
    Array2 [132] var byte
    Array3 [132] var byte
    Array4 [528] var byte
    Array5 [132] var byte
    Array6 [540] var byte
    Array7 [6] var byte
    Array18 [512] var byte
    Array19 [512] var byte
    Array20 [32] var word
    Array21 [32] var word

    Word1 var word
    Word34 var word

    byte1 var byte
    byte27 var byte

    con1 con 255 (byte value)
    con33 con 255 (byte value)

    con34 con 512 (word value)
    con42 con 512 (word value)

    This is just an example of how my variables, arrays and cons are listed in my code.
    At compile, PBP states that only 33116 bytes are used. If I try to increase the size of my arrays, it states that it is unable to fit them in.
    Do the 33116 bytes used include the 5K+ bytes listed as variables, arrays and cons?

    Or am I missing something?

    All feedback is appreciated,


  2. #2
    Join Date
    Oct 2005

    Default Re: Are my variable counts too high?

    You're mixing stuff a bit.
    Variables (BIT, BYTE, WORD, LONG and arrays of these) are stored in RAM. Constants are replaced with there numeric value at compile time and are stored, together with the rest of the compiled program in program memory (FLASH). When you compile your code the reported size is how much room the program takes in FLASH - it's got nothing to do with how many variables you've declared.

    The 18F67K40 has 128kB of program memory (where the compiled code is stored) and 3562 bytes of RAM (where you variables are held during runtime). PBP itself uses some of that RAM, the rest is free for you to use.


  3. #3
    Join Date
    Jun 2017

    Default Re: Are my variable counts too high?

    Thanks for your feedback HenrikOlsson!

    I knew something was off when I made this post. It was my mind! Thanks for clearing this up for me.


Similar Threads

  1. COUNT never counts properly! (16F870)
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 5th September 2016, 15:31
  2. High byte lost in HSEROUT a Word variable
    By Demon in forum General
    Replies: 2
    Last Post: - 7th October 2012, 21:30
  3. Replies: 1
    Last Post: - 7th December 2009, 16:35
  4. Saving COUNTs?
    By jderson in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th April 2009, 17:55
  5. Writing to high/low variable pairs?
    By kevj in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2007, 18:00

Posting Permissions

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