PIC16F690 EEPROM not retaining data


Closed Thread
Results 1 to 10 of 10
  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Unhappy PIC16F690 EEPROM not retaining data

    Hi,

    I've got a very strange behaviour.

    I write data to the internal eeprom with statement such as:

    Code:
        write healed_,healed        
        READ healed_,tempvar
        IF (tempvar != healed) then 
            SOUND speaker,[100,200]
            LCDOUT $fe,1,"writeRoR"
            PAUSE 2000
        ENDIF
    and get no message, which means the write could be verified.
    Then, when I turn off the circuit and turn on again, I display the values in the EEPROM and they are those I set at the time I flashed the PIC:

    Code:
    DATA @10,0,0     'first hit
    DATA @12,0,0
    DATA @14,0,0
    DATA @16,0,0
    DATA @18,0,0
    DATA @20,0,0
    It happens as if the EEPROM does not keep the data I WRITE.

    Would anyone have an idea why??

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Healed, Healed_ AND TempVar are Bytes?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    DATA @10,0,0     'first hit
    DATA @12,0,0
    DATA @14,0,0
    DATA @16,0,0
    DATA @18,0,0
    DATA @20,0,0
    Is the above in the code you are running.
    I display the values in the EEPROM and they are those I set at the time I flashed the PIC:
    If so, every time the PIC starts those values are written. If this is not the case then...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Nope.. DATA is performed at programming time only.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Healed, Healed_ AND TempVar are Bytes?
    healed is a BYTE var
    healed_ is a CON pointing to the EEPROM location where I backup value of healed variabme
    tempvar is a BYTE var

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Code:
    DATA @10,0,0     'first hit
    DATA @12,0,0
    DATA @14,0,0
    DATA @16,0,0
    DATA @18,0,0
    DATA @20,0,0
    Is the above in the code you are running.


    If so, every time the PIC starts those values are written. If this is not the case then...
    Really?
    I thought that DATA @... was only used at the time the PIC is programmed only.
    Then How should I set initial values at programming time???

  7. #7
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Nope.. DATA is performed at programming time only.
    Ah, that's what I thought, otherwise DATA would make no sense.
    There is another instruction to alter EEPROM value: it is READ and WRITE

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello xnihilo,
    what does your code which makes healed_ into an address location look like ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile Problem solved.

    Thank you for your help but this time I could solve the problem:

    I was using a routine that displays at the begining of the program the contents of the EEPROM at location 10 to 21 using an index var (hitnr).
    Then later in the program I was writing to EEPROM using the index var BUT i forgot to reset the index var to its initial value after using it at the begining of my program so I was thinking I was writing to location 10 while the index var was already at 12. So when restarting the pic, I was displaying values of locations 10 and 11, that were still at 0 so I thought EEPROM write failed somehow. I was at the wrong memory offset...
    Stupid error, I should get some sleep

    Have a nice day.

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Stupid error, I should get some sleep
    ME TOO. I was close.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  2. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  4. 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
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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