How to define constants that specify eeprom addresses


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Skip the EEPROM statement, and use DATA.

    If you know the last used EEPROM location from the previous program.
    Start somewhere after that with ...
    Code:
    DATA @128 ; anywhere past the original data
    Then let PBP decide where the rest goes with ...
    Code:
    ee_patnum      DATA 2
    ee_stepnum     DATA 0
    ee_bright      DATA 255
    ee_xfade       DATA 254
    And when you want to retrieve it ...
    Code:
    READ ee_bright, bright
    READ ee_xfade, xfade
    Or write to it ...
    Code:
    WRITE ee_bright, bright
    WRITE ee_xfade, xfade

    If you have PBP 2.60, you can also have DATA Words or Longs.

    hth,
    DT

  2. #2
    Join Date
    Dec 2009
    Location
    Edmonton AB Canada
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thanks, Darrel.

    The main reason that I'm trying to do this symbolically is that the size (amount) of the user data changes. I simply want to maximize the amount of user space available, without having to re-calculate the system addresses when I change PICs.

    Its a lot easier if I can just tell the compiler what the last address is and have it assign system variables automatically, starting from the top and working downwards.

    Part of this learning exercise is developing the techniques I will be using in the future.

    Your example helps a lot - I see how to assign symbol names to specific addresses. That makes it easy to re-write the code to avoid using hard-coded numeric constants as is done currently.

    What I'd like to do now is have the addresses assigned automatically, if that is possible.

    Any ideas?

    Many thanks!

    dwayne

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    EEPROM allocation only increments.

    And whether you're counting from end up or top down, you still need to know where the original program's highest EEPROM location is, and how many bytes you need now.

    Going from end-up will make it longer before you overwrite locations, but it won't keep you from doing it.
    If you start from the end of previous eeprom usage and add more as needed, then the compiler will let you know when you've run out.

    But anyhow, if you know how many bytes you are adding(EEusedNow), and you know how many bytes are available ...
    Code:
    MaxEEPROM    CON 255
    EEusedNow    CON 65
    
    DATA  @MaxEEPROM - EEusedNow + 1
    
    ee_patnum    DATA 2
    ee_stepnum   DATA 0
    ee_bright    DATA 255
    ee_xfade     DATA 254
    
    ;... etc. ...
    DT

  4. #4
    Join Date
    Dec 2009
    Location
    Edmonton AB Canada
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    I think that will work quite nicely.

    I know how many system variables that I have (not many) and I will certainly keep track of the user variables.

    This does exactly what I want: provides me with a single place where I can specify the eeprom size.

    Many thanks!

    dwayne

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  3. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  4. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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