Internal eeprom - erase block


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1

    Default Internal eeprom - erase block

    Hi guys,

    will start making some experiments with saving data to eeprom and dumping the data to lcd or PC via rs232.

    First i will try with the internal eeprom to see how that works and after with an external eeprom.

    I've been reading the pbp manual and will use the write and read commands.

    My first question is :

    My code will need to sart with clearing the eeprom before saving new data ( 1st erase old data then save new data ).

    Is there a simple way to erase ( by code ) all internal eeprom memory at the beggining of the program ?

    Thanks
    .

  2. #2
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    So you want to erase the eeprom every time the pic is started?

    I'm rather new to pics and PB, but I'll give you my opinion .

    Maybe you can add something like:

    w0 var word
    for w0 = 0 to 255 'It depends on how many slots you want to erase, I'm erasing 256
    write w0, 0 'We write a zero to the eeprom at the desired location, like erasing it
    next w0 ' we continue with the next w0

    hope this helps.

    By the way, there's the Data command, with it you can preset the eeprom to whatever you want at the time of the programing. You add Data @0,2,6, 3, 50, etc at the beginning of your program and when your program your pic (not every time you power it up) the eeprom recieves the values you specified, in this case:

    eeprom 0 = 0
    eeprom 1 = 2
    eeprom 2 = 6
    eeprom 3 = 3
    eeprom 4 = 50

    bye

    Art

  3. #3
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Look at what I found. Darrel creates some really awesome extensions all the time, maybe this one will help you with what you are doing.

    http://www.picbasic.co.uk/forum/showthread.php?t=2444

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Check this one.
    Modify as needed.


    Code:
    ReadMem VAR BYTE
    Value   VAR BYTE
    
    Begin:
    
        FOR ReadMem = 0 TO 128  'Scan eeprom
            READ ReadMem, Value 
            IF Value <> $FF THEN Start
        NEXT ReadMem
    
    Start:
    
    ' your "value" variable gets a value here.
    '..
    '....
    
    ' when you want to save something into eeprom, goto "save".
    
    GOTO Start
    
    
    Save:
                IF ReadMem = 128 THEN    ' last eeprom location. 
                   WRITE 0, Value        ' thus, start from the beginning
                   WRITE 128, $FF        ' assign $FF to last written eeprom location.
                ELSE
                   WRITE ReadMem + 1, value 'save your value into eeprom after the current eeprom address.
                   WRITE ReadMem, $FF       'assign $FF to the current eeprom location.
                ENDIF                       'new eeprom location will be incremented,
                GOTO Begin               '...with the next eeprom scan.
    Last edited by sayzer; - 27th December 2007 at 16:08. Reason: edited code with minor modification....
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5


    Did you find this post helpful? Yes | No

    Default

    atwoz,

    thanks for the help...also...very interesting link

    sayzer,

    also thanks for the help.

    Nice code

    If i understand it will search the eeprom for a good value, send it to "start" to process it.
    Then when saving, saves the new value to the eeprom and deletes the previous address value.

    This can be very handy

    Although what i will be using is more like this:

    1st : erase all eeprom if button #1 pressed
    2nd : send all data stored in eeprom via rs232 if button #2 pressed
    3rd : start collecting data and saving it to eeprom if button #3 pressed
    4th : stop collecting data and go back to starting loop if button #4 pressed


    Since the data being colected and saved into the eeprom will be unique ( meaning that everytime the pic restarts and will if it will colect data it cannot be mixed with old data ) the entire eeprom will have to be deleted and ready to receive o toon of fresh continuous data.

    .

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I see.

    But, if you are erasing eeprom very frequently in your application, I do not now what "very frequently means ??", then your eeprom will be dead "very soon".

    Then, very soon, your customers will be calling you "very frequently".
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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. config bits
    By brianD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th February 2010, 13:45
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 15:26
  5. Internal EEPROM Read/write Addressing Errors with 18F PIC's
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 18
    Last Post: - 12th July 2005, 19:42

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