PBP RAM allocation - how to find available or total used RAM?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,695


    Did you find this post helpful? Yes | No

    Default Re: PBP RAM allocation - how to find available or total used RAM?

    It should be the entire RAM area of the particular pic’s memory map of one bank.
    Then the same area is usually mirrored in other banks, so I’d just change the bank and run the same code again.
    there is no need to do it that way , most pic chips that have enough ram to consider this treatment will be pic18 or enhanced core pic16's
    with an ability for linear memory access anyway , otherwise there is no point
    scanning the memory is dead easy , marking the used area is the difficult part.
    lumping all your vars into arrays and using EXT referencing for each individual var is impractical , and what about include files
    Warning I'm not a teacher

  2. #2
    Join Date
    Nov 2016
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: PBP RAM allocation - how to find available or total used RAM?

    Thanks for all the suggestions...

    The idea of an external program seems most "secure" but it's not really "friendly"... and it could be simply done if using ASM only (no PBP) but the point was in using/extending PBP...

    This "unfriendliness" is because of the fact that you should manually or with this program, alter an variable definition so to have that information available in runtime.

    What I mean with this something like having a FLASH location with a dw _SYS_FREE_START_ (holding the value of first free ram location) so it could be used by the program for "dynamic allocations".

    What I'm trying to accomplish is a "poor man" malloc() functionality (no, free(), no realloc()...) and for this I need the "free" info in runtime. So, with various programs and similar, you have to "manually" change that value in source and recompile to get the desired effect.

    After some fiddling around and I think I found a "relatively good" solution:

    declare an byte array which name is alphabetically last in order and which is bigger than any other defined byte array in your program. This kind of variable seems to be placed last in ram.

    This method assumes:
    - no direct allocations (with $address modifier) used in the program or at least you must be sure such addresses are before your other allocations
    - no specific BANK n modifiers (other than BANKA/BANK0 or be sure to have enough other variables to use some bank "later" - example: if you use BANK 3 be sure to have enough variables to fill BANK0, 1, 2)
    - enough free space to declare an byte array bigger than other used byte arrays (this seems reasonable if you need a malloc() anyway)


    So, for example, if you declare
    Code:
    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz var byte[1000]
    and put somewhere something similar
    Code:
    @_RAM_FREE dw _zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
    you should be relatively sure the flash at address _RAM_FREE has the address of the first available RAM location.

    That can value could be put in a word var instead of flash for later use (as I mentioned - malloc())

    So... if anyone needs a "dumb" malloc()...

    This "malloc()" stuff can be easily used on 18F and on 16F "enhanced core" PICs... but mainly from ASM.

    Regards,
    MCulibrk

Similar Threads

  1. Need Help ON the SPI F-RAM....
    By hankshone in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th February 2010, 19:29
  2. RAM not reseting
    By InitialDriveGTR in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd January 2010, 20:24
  3. RAM test
    By Sach_1979 in forum General
    Replies: 0
    Last Post: - 24th September 2009, 23:12
  4. Ram Gets Cleared
    By ljubex in forum General
    Replies: 2
    Last Post: - 7th November 2005, 00:38
  5. And last but not least: static ram?
    By bearpawz in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st November 2004, 05:37

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