Internal eeprom - erase block


Results 1 to 33 of 33

Threaded View

  1. #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 17:08. Reason: edited code with minor modification....
    "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, 15:46
  2. config bits
    By brianD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th February 2010, 14:45
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 01:55
  4. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 16: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, 20:42

Members who have read this thread : 0

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