Easier way to initialize EEPROM


Go to last post By: charliecoultas
Today 15:24
Forum: Proton 24
Starter: charliecoultas
Views: 0
Replies: 3
Yesterday 21:01
Forum: GPS
Starter: david
Views: 0
Replies: 6
Yesterday 20:40
Forum: GPS
Starter: SimonJA
Views: 0
Replies: 26
+ Reply to Thread
Results 1 to 8 of 8

Thread: Easier way to initialize EEPROM251 days old

  1. #1
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,681
    Thumbs Up
    Received: 15
    Given: 15
    Total Downloaded
    750.96 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. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,589
    Thumbs Up
    Received: 66
    Given: 91
    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

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,681
    Thumbs Up
    Received: 15
    Given: 15
    Total Downloaded
    750.96 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

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    420
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    2.11 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

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,681
    Thumbs Up
    Received: 15
    Given: 15
    Total Downloaded
    750.96 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

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,234
    Thumbs Up
    Received: 76
    Given: 38
    Total Downloaded
    2.91 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.

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,396
    Thumbs Up
    Received: 90
    Given: 23
    Total Downloaded
    4.04 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

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Prolific Poster shantanu@india's Avatar
    Join Date
    Feb 2007
    Posts
    1,681
    Thumbs Up
    Received: 15
    Given: 15
    Total Downloaded
    750.96 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

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

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 18th December 2018, 18:51 : 1

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