Today 17:07
Forum: Proton Plus Compiler v3
Starter: rcurl
Views: 0
Replies: 16
Today 16:52
Forum: Website / Forum Issues
Starter: pe1pme
Views: 0
Replies: 65
Today 15:08
Forum: The Lounge
Starter: basparky
Views: 0
Replies: 5
Today 14:47
Forum: Website / Forum Issues
Starter: fanie
Views: 0
Replies: 5
Today 13:31
Forum: The Lounge
Starter: Henk57
Views: 0
Replies: 114
Today 12:47
Forum: The Lounge
Starter: craig
Views: 0
Replies: 2
+ Reply to Thread
Results 1 to 8 of 8

Thread: Easier way to initialize EEPROM90 days old

  1. #1
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,663
    Thumbs Up
    Received: 13
    Given: 15
    Total Downloaded
    675.23 MB

    0 Not allowed!

    Default Easier way to initialize EEPROM

    Hi,
    I have to initialize the EEPROM of a 80-step Air Dryer Controller(based on 18F24K22 with 256 byte EEPROM) with the default values of 80 time intervals , 80 Temperature settings & 80 Rh settings in the following manner......

    Interval Edata Byte 15,15,15,15.............80 bytes each holding the default value of 15 minutes

    Temperature Edata Byte 60,60,60,60............80 bytes each holding the default value of 60 deg C

    RH Edata Byte 30,30,30,30............80 bytes each holding the default value of 30% humidity

    Is this the only way of bulk initialization of the EEPROM........it is too tedious!!

    Any other ways??
    Thanks.
    Shantanu

  2. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,519
    Thumbs Up
    Received: 55
    Given: 86
    Total Downloaded
    895.24 MB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    Not sure exactly what is onerous about writing the edata out once during programming. Afew cut paste blocks will do it in a min or 2.


    If the values have to be different every time I would fill the array in program at startup. Set a flag to say its been done or just read in the top value. If it's $55. Then run the erwite loop.

    Next time you power up the value is not $55 so no write needed.

    Tim
    Tim

  3. #3
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,663
    Thumbs Up
    Received: 13
    Given: 15
    Total Downloaded
    675.23 MB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    Good idea Tim.....
    Fortunately , my default values are going to be same for all controllers.
    Shantanu

  4. #4
    Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    389
    Thumbs Up
    Received: 28
    Given: 4
    Total Downloaded
    1.70 GB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    I assume the EEPROM data contains an initial default value, if so and it is not a value that you would expect to occur within your application then you could read the first address (or first & last) to see if it hold the default value or an application specific value. If it holds the default vaule then use a loop to populate the EEPROM with the initial application values. Something like...

    Code:
    Goto Main:
    
    Populate_EEPROM:
    For I = 0 to 80    'Interval Data
    Edata 15
    Next 
    
    For I = 0 to 80    'Temperature Data
    Edata 60
    Next 
    
    For I = 0 to 80    'Humidity Data
    Edata 30
    Next  
    Return
    
    Main:
    Variable = Eread 0
    If Variavle = Default then gosub Populate_EEPROM

  5. #5
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,663
    Thumbs Up
    Received: 13
    Given: 15
    Total Downloaded
    675.23 MB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    Hi Stephen,
    Thanks but "Edata" cannot be used inside the basic code as you have suggested.
    An extract from the Proton compiler manual:

    Any Edata directives must be placed at the head of the BASIC program as is done with Symbols,
    so that the name is recognised by the rest of the program as it is parsed. There is no need
    to jump over Edata directives as you have to with Ldata or Cdata, because they do not occupy
    code memory, but reside in high Data memory.
    Shantanu

  6. #6
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,182
    Thumbs Up
    Received: 70
    Given: 37
    Total Downloaded
    2.68 GB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    I don't agree with the manual. I stick Edata at the very end of the code, and it gets put into EEPROM ok.
    But on re-reading your last post I see that this might not be the case!

    ..last line of code
    Edata $12, $13, $14 etc

    Charlie
    Last edited by charliecoultas; 17th May 2018 at 12:20.

  7. #7
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,292
    Thumbs Up
    Received: 75
    Given: 23
    Total Downloaded
    3.27 GB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    I do the following whenever I need to begin with a default value, in your case the following: -


    Code:
    If ERead 0 > 0 Then         ' Check if it the first time that PIC is running this code.
        GoSub Default           ' If yes, gosub First_On
    EndIf                       ' End If...Then instruction
    
    '=======================================================================================
    
    Main:
    
    ' Your Main code here
    
    GoTo Main
    
    '=======================================================================================
    
    Default:
    
    For I = 1 To 81    'Interval Data
        EWrite I , [15]
        DelayMS 10
    Next 
    
    For I = 82 To 162  'Temperature Data
        EWrite I , [60]
        DelayMS 10
    Next 
    
    For I = 163 To 243 'Humidity Data
        EWrite I , [30]
        DelayMS 10
    Next  
    
    EWrite 0 , [0]
    
    Return
    
    '=======================================================================================

    When the PIC is erased usually eeprom is filled with $FF, so I check address 0 to see if value is greater than 0. If it is, then I Gosub to load default values in eeprom locations.


    I also find it usefull so if I have to get those data to default after i.e. a press of a button I Gosub to this routine to load defaults again.
    Last edited by joesaliba; 17th May 2018 at 17:38.
    Regards

    Joseph

  8. #8
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,663
    Thumbs Up
    Received: 13
    Given: 15
    Total Downloaded
    675.23 MB

    0 Not allowed!

    Default Re: Easier way to initialize EEPROM

    Nice approach Joseph......Tim also gave a similar idea.
    Will adapt in future.
    Shantanu

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. 16F18326 - I cannot initialize
    By Robertux in forum Oscillator Modules
    Replies: 11
    Last Post: 11th October 2017, 19:58
  2. How to re-initialize an LCD display
    By rcurl in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 21st August 2005, 02:48
  3. easier way to print LCD char
    By C_Moore in forum Wish List / Product Feedback
    Replies: 0
    Last Post: 2nd April 2005, 00:55

Members who have read this thread since 11th August 2018, 10:06 : 0

Actions :  (Set Date)  (Clear Date)

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