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

    Well, I have another question. I have been examining the .asm and .lst files to try to understand how macros create code and better grasp the EE_vars program. I found a variable called EE_VarCount that is EXT (external?) which I believe means it is not available in the actual downloaded code.

    Can help me better understand what happens when the EE_Vars program is run the 2nd time after initialization is complete? I understand that:

    EEPROM EE_Start, [0]

    Sets EE_Start to zero on 'first run' only. At the end of initialization EE_Start contains the number of EE_Vars assigned. After that I assume that EE_Start is never written to correct? Can you give me some insight into what the program does on 2nd and consecutive runs. What is it examining to know that it is finished with initialization? Is there a variable I can look at to know to see what happens?

    Thanks again, Bob

  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
    I found a variable called EE_VarCount that is EXT (external?) which I believe means it is not available in the actual downloaded code.
    If you do a FIND (ctrl-F) and type in EE_VarCount, you'll see that variable used many times in the program. So yes, it IS in the actual downloaded code.

    Can help me better understand what happens when the EE_Vars program is run the 2nd time after initialization is complete? ...
    I already went through that in post#38.
    I understand that:
    EEPROM EE_Start, [0]
    Sets EE_Start to zero on 'first run' only. At the end of initialization EE_Start contains the number of EE_Vars assigned. After that I assume that EE_Start is never written to correct?
    Correct.
    What is it examining to know that it is finished with initialization? Is there a variable I can look at to know to see what happens?
    Again, it's looking at the EEPROM location designated by the EE_Start constant. (post#38)

    Look, we can go round and round trying to blame the Tried and Tested code (EE_vars), or we can try to find the problem in your program, which you seem to have stopped looking at.

    You get to see all my code.
    I need to see yours.
    The whole thing, not just 10 lines somewhere that might apply.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi again Bob,

    After another similar question from a different user, I've found a possible reason for your problems.
    Of course, there's no way to verify it because I still haven't seen your code, but ...

    Something I didn't realize before is that the DATA and EEPROM statements use the same internal "counter" to keep track of the next available EEPROM location.

    So if the EE_start location is changed to a higher value, and DATA statements come AFTER the EE_vars include file, then the DATA statements will place the data in the same locations that EE_vars uses, instead of 0 like expected.

    In other words, to do what you were trying to do, the DATA statements would have to be placed PRIOR to including the EE_vars module.

    hth,
    DT

  4. #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Subliminal texts going on?

    Hi Darrel,
    I'm just beginning to use the EEPROM of the PIC12F683 on the LAB-X4 platform with PB Pro 2.47 and using the MPASM compiler.
    I downloaded the EE_Vars.PBP.txt file and copied it to my PBP folder where I resaved it as EE_Vars.PBP, I think I did right.
    The good stuff:
    I also download your EE_example_1 file to experiment with. After configuring the LCD setup, it works as advertised!
    Code:
    '****************************************************************
    '*  Name    : EE_1_Example.bas                                  *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : 8/27/2005                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : This is an Example program for the EE_Vars.PBP    *
    '*          : Include file.                                     *
    '****************************************************************
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF 
    OSCCON = %01110001  ' Osc 8Mhz
    ANSEL = %00111000	' Fosc/64 and ANS3 set to analog
    ADCON0 = %10001100  ' Right justified and AN3 selected
    CMCON0 = 7		    ' Analog comparators off
    GPIO = %00111101    ' Set all ports to inputs except port 1
    TRISIO = %00111101  ' Port 1 to output, rest inputs
    
    ;-- Define LCD connections -- (change these to match your hardware) ------------
    Include "modedefs.bas"	' Mode definitions for Serout
    INCLUDE "EE_Vars.PBP"           ; Include the EE_var routines
    
    define OSC 8          ' Declare for PAUSE and PAUSEUS statements
    pause 1000
    '=========================================================================
    '                         Variable pin names
    '========================================================================= 
    '       Var GPIO.0      ' Pin 7
    LCD 	Var	GPIO.1	   	' Pin 6
    '       Var GPIO.2      ' Pin 5
    '       Var GPIO.3      ' Pin 4
    '       Var GPIO.4      ' Pin 3
    '       var GPIO.5      ' Pin 2
    
    
    
    Days    VAR WORD  :  @  EE_var  _Days, WORD, 365
    Cats    VAR WORD  :  @  EE_var  _Cats, WORD, 1024
    Mice    VAR WORD  :  @  EE_var  _Mice, WORD, 10000
    PowerOn VAR BYTE  :  @  EE_var  _PowerOn, BYTE, 0
    
    PowerOn = PowerOn + 1           ; Increment number of Power-On cycles
    @ EE_write_var  _PowerOn        ; save the new number to EEPROM
    
    Serout LCD, T2400, [$fe, 1]	' Clear screen
    pause 1000
    Serout LCD, T2400, ["Days= ",#Days," Cats= ",#Cats]
    pause 100 
    Serout LCD, T2400, [$fe, $c0,"Mice= ",#Mice," PowOn= ",#PowerOn]
    pause 100
    
    RANDOM Mice                     ; get a new value for Mice
    @    EE_write_var  _Mice        ; save it to EEPROM
    
    stop
    The funny stuff:
    If I first select and copy any one of the EE variables such as:
    Code:
    PowerOn VAR BYTE  :  @  EE_var  _PowerOn, BYTE, 0
    and change the Byte to a Word in both cases here, it gets mad when I compile it and reports these errors:
    Error[113] c:\program~on and on~ee_1_e~.asm 163: Symbol not previously defined (Byte)
    Error[113] c:\program~on and on~ee_1_e~.asm 172: Symbol not previously defined (Byte)
    Error[113] c:\program~on and on~ee_1_e~.asm 173: Symbol not previously defined (Byte)
    So now if I change it back to BYTE in both cases, it still gets mad after compiling.

    Here's the stranger part: I now select the troubled line of code and paste the original line of code prior to all this and the compiler is happy once more!?

    I only tried this because when I wrote my own and got these messages, they stopped when I commented out my EE declaration lines and "pasted" your lines instead.

    Are you using subliminal texts for this routine? Or did I not copy the Include file properly into my program?
    Louie

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


    Did you find this post helpful? Yes | No

    Default

    Watch the CASE of the parameters.
    Use WORD or BYTE instead of Word or Byte.

    You can tell from the error message ... Symbol not previously defined (Byte).
    <br>
    DT

  6. #6
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Exactly!

    Thanks again for your efforts Darrel!
    That was it exactly. It turns out that I took the editor's "Auto cap" feature for granted when I typed the parameters. It's turned me into "Auto lazy".

    That feature is no more.

    Thanks again...
    Louie

  7. #7
    Join Date
    May 2010
    Location
    Chile
    Posts
    25


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel,

    As usual your INCLUDES are awesome.


    P.D.: I would buy you a beer but then is the problem of distance

    Any local brewery that takes online orders?

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    Hi Darrel,

    Just found your EE_Vars.PBP include file and have been playing around with it - thanks for making the documentation so thorough; it made getting started very easy. Is it possible to use a variable/constant/symbol in the default value portion of EE_var? Something like this:

    Code:
    NacelleSpeed VAR WORD  :  @  EE_var  _NacelleSpeed, WORD, initNacelleSpeed
    MPASM throws this error no matter how I set up initNacelleSpeed (variable/constant/symbol):

    Code:
    Error[113] c:\pbp~1\pbp2.60c\ee_2~1.asm 122 : Symbol not previously defined (initNacelleSpeed)
    Thanks,
    Ross

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, 14:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03: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, 14: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, 06:26
  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 : 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