EEPROM Variables (EE_Vars.pbp)


Closed Thread
Results 1 to 40 of 80

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Thanks, Darrel. I really like your program and am starting to experiment with it. The way I was working with EEProm Vars was quite the convoluted mess with the same problems you mentioned in your EE_Vars documentation. Hopefully this will make life easier.

    So from what I understand if I just set the value in EE_start to zero everything gets reinitialized when I reset the pic.

    So if I use EE_Vars to link numerous variables as follows:

    msType VAR SysDat[51]:@ EE_var _msType, WORD, 0

    Does the compiler insert the macro code for each variable? Is there a lable created by the macro to find the default values for each variable? I'm just trying to understand how this works a little better.

    I have a case where I may want to loop through a group if variables and save them to EEProm, is there a way to do this using EE_Vars.

    Can you recomend any reading to better familiarize myself with macros?

    Thanks again for your help and for posting the EE_Vars program.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by brittons View Post
    Thanks, Darrel. I really like your program and am starting to experiment with it. The way I was working with EEProm Vars was quite the convoluted mess with the same problems you mentioned in your EE_Vars documentation. Hopefully this will make life easier.
    You are very welcome, and I hope it helps you too.

    > So from what I understand if I just set the value in EE_start to zero everything gets reinitialized when I reset the pic.

    Correct!

    > Does the compiler insert the macro code for each variable? Is there a lable created by the macro to find the default values for each variable? I'm just trying to understand how this works a little better.

    Yes it does, and this will probably add more confusion instead of answering the question, but since you want to learn, here goes.<hr>

    When you create an EE_var, several of it's properties are stored as Constants in the assembler.
    For this variable ...

    MyVar VAR WORD : @ EE_var _MyVar, WORD, 1000

    Between the EE_var and EE_assign macros, it will create the following constants.

    Code:
    EE_Var1_Default     = 1000    ; the Default value
    EE_Var1_PTR         = 1       ; the address of the data in EEPROM
    EE_Var1_Size        = 2       ; size of the variable
    EE_Var1_HasVariable = 1       ; 1 if Linked to a PBP variable
    EE_Var1_Variable    = 60      ; Address to the PBP variable that's linked
    EE_VarLink60        = 1       ;  and a way to find the "link" from the variable
    If you create a second EE_var ...

    SecondVar VAR BYTE : @ EE_var _SecondVar, BYTE, 75

    it would create these constants ...
    Code:
    EE_Var2_Default     = 75      ; the Default value
    EE_Var2_PTR         = 3       ; the address of the data in EEPROM
    EE_Var2_Size        = 1       ; size of the variable
    EE_Var2_HasVariable = 1       ; 1 if Linked to a PBP variable
    EE_Var2_Variable    = 62      ; Address to the PBP variable that's linked
    EE_VarLink62        = 2       ;  and a way to find the "link" from the variable
    At this point, they're all just a bunch of constants. They don't do anything, and they haven't used any code space. But you can see them in the "Symbol Table" at the bottom of the .lst file.

    And in an odd sort of way, it becomes a "database" of information that you can query for the desired results.

    For instance, if I know the variable name (SecondVar), and I want to know which EEPROM variable has been "linked" to it?
    Using the same Text Substitution that the macro's use ....

    TheEEvar = EE_VarLink#v(_SecondVar)

    The #v(_SecondVar) part is the "Text Substitution". It will be replaced with the value inside the brackets. In this case it's the address of the variable which was 62.

    So it turns into ...

    TheEEvar = EE_VarLink62

    Which returns 2. The second EE_var that was linked to a PBP variable.

    Now that you know which EE_var was linked to it, you can use that value to query the other parameters.

    <pre>EE_Default = EE_Var#v(TheEEvar)_Default<br>EE_Loc = EE_Var#v(TheEEvar)_PTR<br>EE_Size = EE_var#v(TheEEvar)_Size</pre>This pulls up all the pertinent data about that EE_var. Which is what the GetEEinfo macro does.

    If you want to use those constants in PBP, all you need to do is declare a CON EXT for each one.
    Code:
    EE_Default  CON EXT
    EE_Loc      CON EXT
    EE_Size     CON EXT
    And walla, a variable database, with zero code space. <hr>
    If none of this makes any sense, don't worry. I write this stuff for everyone. Someday, someone will slap themself on the forehead and go. "That's It!". And if not now, six months from now might result in the same slap. Which of course, makes me "Slap Happy".


    > I have a case where I may want to loop through a group if variables and save them to EEProm, is there a way to do this using EE_Vars.

    Well, EE_vars wasn't set up for persistent Arrays. It's not that it can't be done. I just didn't do it.

    > Can you recommend any reading to better familiarize myself with macros?

    I'll say the same thing I always say ...
    If you want to learn Macro's, you already have the best "Interactive" tutorial there is ... PBP.

    For all the things you can do with PBP, you can create a 1-line program. More when you get better at it. That answers the specific question you may have. Like, "how do I set a port to Output?

    Just create a small program that has 1 line ...

    OUTPUT PORTB.0

    After you compile it, you'll find a .ASM .MAC and .LST file in the folder that the original program was in.
    Start with the .ASM

    Those files will give you more insight into the workings of macro's, than ANY book I've ever seen.

    Really, no I'm serious. Try it!
    You can ask it any question (that PBP can do), and you'll get an answer that relates to your question, instead of an example to some project that the book was based on.
    DT

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I'll say the same thing I always say ...
    If you want to learn Macro's, you already have the best "Interactive" tutorial there is ... PBP.
    ...
    Those files will give you more insight into the workings of macro's, than ANY book I've ever seen.

    Really, no I'm serious. Try it!
    You can ask it any question (that PBP can do), and you'll get an answer that relates to your question, instead of an example to some project that the book was based on.
    I whole heartedly aggree with Darrel on this, but with one correction: With PBP and Darrel's include files, you have got the best tutorial possible.

    Also, for details, the help file for MPASM assembler has info about syntax and stuff that can be helpful as well.

    Steve

  4. #4
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Thanks SO MUCH! This stuff just fascinates me. I have to buckle down and start working with macros. Thanks for the insight into learning by doing. It's pretty much the way I've learned what I already know but I just wanted to see if anyone else had the light bulb turned on by something they stumbled across.

    Darrel, when you stated that I could use the folowing constants in PBP do you mean I can examine the values after running EE_var or EE_assign and I would see the values of these three vars change in PBP according to the var assigned? Should I still use CON or should I use VAR? If I know the starting location of an EEProm var and the first element of my Array of vars starts at EE_Loc couldn't I loop through the elements and save them at the correct location? Of course my EE_Var assigns have to be assigned consecutively.

    EE_Default CON EXT
    EE_Loc CON EXT
    EE_Size CON EXT

    I did save a piece you wrote on EXT, I probably should go back and examine that.

    Thanks, Bob

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 15:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 04:17
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 07:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

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