Going back to basics, some advice on memory storage


Closed Thread
Results 1 to 8 of 8

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Going back to basics, some advice on memory storage

    sorry about the sarcasm ,but doing it your way that's a lot of typing

    still
    DATA 8,CH1_Max.lowbyte
    DATA 9,CH1_MAX.highbyte
    DATA 10,CH2_Max.lowbyte
    won't work data can only store constants

    data @8, 123,34,23,15 ........................ for the other 92 values

    and it can be readback with read
    Last edited by richard; - 23rd March 2016 at 23:17. Reason: @fell off

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Default Re: Going back to basics, some advice on memory storage

    DATA is used to store the value(s) in the EEPROM when the device is programmed. Ie. to get a "default" value in there. It's embedded in the .hex file image which get programmed into the device.
    WRITE is used to store values in EEPROM during runtime.
    It doesn't matter HOW the values got there, READ will access them.

    You don't really have to keep track of the adresses etc, you can do
    Ch1_On_Time DATA WORD 1234
    Ch1_Of_Time DATA WORD 2345

    This way you have created a label for each entry in the EEPROM which you can then use when your READ or WRITE from/to it in your code. Please note that Ch1_On_Time in this case is NOT your variable - it's ONLY a label. To actually USE it in your program you need to READ it from EEPROM and Place it an ordinary variable - but you're already doing that.

    Using arrays, the EXT modifer, and indexing thru the data as in Richards example is probably more efficient code wise but may not be the easiest way to debug and/or understand. YMMV.

    /Henrik.

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Going back to basics, some advice on memory storage

    Henrik,

    Thank you for your very informative post. I agree that Richards guidance in using the array and modifier makes for tighter compact code. I just thought that in this case it might of muddied the water a little when I was trying to explain my question.

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Going back to basics, some advice on memory storage

    Henrik,

    If I follow your post correctly I can do the following

    Code:
    DATA @8,0 
    
    EE_CH1_Max DATA WORD 4095
    EE_CH2_Max DATA WORD 4095
    
    etc
    and then

    Code:
    read EE_CH1_Max, WORD CH1_Max
    read EE_CH2_Max, WORD CH2_Max
    The part I can't get my head round is assuming you place the data statement at the start of the code so this happens when the code is run, what distinguishes it from a fresh install and a reboot as surely the code is executed from the start when powered up and will use the data command when it reaches that line of code ?

  5. #5
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Going back to basics, some advice on memory storage

    Oh it's so much easier with labels than using all that location, lowbyte hughtbyte stuff !!!

    I now have a set of preset values loaded first time after the chip is programmed, and user variables saved once changed by the user, which are retained in the event of a power fail...

    Now to do a few more bits before following Richards examples to tidy up the code and make ot a bit more compact...

Similar Threads

  1. I2C storage issue
    By lerameur in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th November 2010, 19:42
  2. Memory Overflow? Urgently need advice
    By curian88 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th April 2010, 14:42
  3. data storage label
    By MINHLE in forum General
    Replies: 6
    Last Post: - 17th December 2009, 14:04
  4. internal storage space?
    By gtrplaya101 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th October 2009, 06:45
  5. The basics
    By malc-c in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 22nd June 2008, 00:09

Members who have read this thread : 0

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