Ram management / Hi


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2008
    Posts
    6

    Smile Ram management / Hi

    Dual purpose post,

    First let me say Hi, I’m a new PIC user, migrating from the basic stamp.

    Second is a question,
    It may be my paranoia from the stamps but how does one keep up with the RAM usage?

    I have been using statements like:

    SOMEPIN VAR PORTB.0

    Does the compiler just place PORTB.0 in the places I type SOMEPIN, like a CON, or is there a variable created because of that statement?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    You have direct access to the pin.

    Ioannis

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Lightbulb

    Quote Originally Posted by 124C41 View Post

    SOMEPIN VAR PORTB.0
    Hi

    That means "SOMEPIN" is just another name for PORTB.0

    consider it as a compiler DIRECTIVE ... that doesn't change the produced code.

    Compiler just replaces all the "SOMEPIN" strings it finds by the "PORTB,0" string ( it's assembler that is generated ...) so, once declared, you can use one or the other ... when you want in your program.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Nov 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    ok thanks

    Is there an easy way to see the amount RAM used?

    The manual says the compiler uses about 24 bytes for system variables, if the PIC has 256 Bytes RAM is it safe to assume that the user has (256 – 24 = ) 232 bytes to use for variables?

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


    Did you find this post helpful? Yes | No

    Default

    A simple way to check how much RAM is used/available is to open the .asm file generated
    after compiling.

    Example;
    Code:
    DEFINE OSC 20
    
    X VAR PORTB
    Y VAR BYTE
    
    loop:
      FOR Y = 0 TO 7
        HIGH 0          'Turn on LED connected to RB0
        Pause 50       'Delay for .5 seconds
        Low 0           'Turn off LED connected to RB0
        Pause 50       'Delay for .5 seconds
      NEXT Y
        GoTo loop       'Go back to loop and blink LED forever
        End
    File name blink.bas. Open blink.asm after compiling, and you'll see something like this;
    Code:
    #define		OSC		 20
    
    RAM_START       		EQU	00020h
    RAM_END         		EQU	001EFh
    RAM_BANKS       		EQU	00004h
    BANK0_START     		EQU	00020h
    BANK0_END       		EQU	0007Fh
    BANK1_START     		EQU	000A0h
    BANK1_END       		EQU	000EFh
    BANK2_START     		EQU	00110h
    BANK2_END       		EQU	0016Fh
    BANK3_START     		EQU	00190h
    BANK3_END       		EQU	001EFh
    EEPROM_START    		EQU	02100h
    EEPROM_END      		EQU	021FFh
    
    R0              		EQU	RAM_START + 000h
    R1              		EQU	RAM_START + 002h
    R2              		EQU	RAM_START + 004h
    R3              		EQU	RAM_START + 006h
    R4              		EQU	RAM_START + 008h
    R5              		EQU	RAM_START + 00Ah
    R6              		EQU	RAM_START + 00Ch
    R7              		EQU	RAM_START + 00Eh
    R8              		EQU	RAM_START + 010h
    FLAGS           		EQU	RAM_START + 012h
    GOP             		EQU	RAM_START + 013h
    RM1             		EQU	RAM_START + 014h
    RM2             		EQU	RAM_START + 015h
    RR1             		EQU	RAM_START + 016h
    RR2             		EQU	RAM_START + 017h
    _Y               		EQU	RAM_START + 018h
    PBP system variables are from R0 to RR2. Your Y variable is the last one at 018h.

    Depending on how complex your BASIC program is, PBP might need to create a few
    temporary variables. If it does these will show up in the .asm file like the ones above.

    RAM_START and RAM_END will change depending on the PIC you compile for.
    Regards,

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

  6. #6
    Join Date
    Nov 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Thank you very much

Similar Threads

  1. 12F629 LDR - Light Dependant Resistor
    By Dennis in forum Schematics
    Replies: 15
    Last Post: - 18th February 2010, 23:33
  2. On-Chip RAM
    By DaveC3 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 28th July 2008, 11:16
  3. Using the DS1302 scratchpad RAM ?
    By Kman in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 17:27
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 12:47
  5. 18f452 tables in ram - code?
    By rshanks in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st October 2004, 06:06

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