LockedWhy data lost from EEPROM (18F4550)

Author
Guest
Super Member
  • Total Posts : 80500
  • Reward points : 0
  • Joined: 2003/01/01 00:00:00
  • Location: 0
  • Status: online
2006/06/05 12:46:00 (permalink)
0

Why data lost from EEPROM (18F4550)

I wrote a program writing to or reading from EEPROM with chip PIC18F4550. I can do this sucessfully. But I noticed sometime the data in EEPROM are lost after the system was powered off and on several times. Any idea of the possible problem? Thanks for any suggestions.
#1

12 Replies Related Threads

    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/05 12:53:44 (permalink)
    0
    Exactly what do you mean by "lost"? Individual bytes or the whole EEPROM-area? Does it always get the same value?

    If your processor loses power in the middle of a write, that byte will probably be "lost"..
    #2
    jtemples
    Super Member
    • Total Posts : 11007
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/05 13:01:11 (permalink)
    0
    Is the PIC protected from brownout?
    #3
    Guest
    Super Member
    • Total Posts : 80500
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Why data lost from EEPROM (18F4550) 2006/06/05 23:33:34 (permalink)
    0
    Hello! I am also having the same problems with my data EEPROM. My situation is my PIC is used in an automotive environment. I think what fandudu meant was for example address 0x00 of the data EEPROM was supposed to contain 0xAA, it is overwritten by some other values besides 0xAA or maybe an unused memory location like address 0xFE gets to be written by garbage values. In addition, are there any write protect routines or configuration bits that maybe used during runtime? From what I know, it can only be set once during program assembly by setting the CONFIG bits. Lastly, how does brown out reset prevent or avoid unwanted writes?
    #4
    danish.ali
    Super Member
    • Total Posts : 1714
    • Reward points : 0
    • Joined: 2004/11/16 02:02:02
    • Location: Surrey, UK
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 00:38:19 (permalink)
    0
    Hi jc_lim3,
    I think it would be better if you could start your own thread for your problem. The reason I say this is that although the initial symptoms of your problem might be similar, the precise cause or omission is most probably different.
    (Unless you are collaborating with fandudu, but you do not make this obvious in your post).

    Regards,
    Danish
    #5
    DINAELEC
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2003/11/07 12:51:59
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 01:24:37 (permalink)
    0
    hi
    can u send your code for eeprom write and read..
     
    #6
    Guest
    Super Member
    • Total Posts : 80500
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 07:06:40 (permalink)
    0
    Thanks for all replies. My situition is exactly as jc_lim3 said, the data saved in EEPROM are all changed to 0xFF, sometime not always. I believe the program write to EEPROM is correct since I can read right data from EEPROM most time. I guess it lost bacause of the configuration. Here is my configuration set by the program.

         __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
        __CONFIG _CONFIG1H, _FOSC_INTOSC_XT_1H & _FCMEM_OFF_1H & _IESO_OFF_1H
        __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_3_2L & _VREGEN_OFF_2L
        __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_1_2H
        __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _LPT1OSC_OFF_3H & _PBADEN_ON_3H & _CCP2MX_OFF_3H
        __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _XINST_OFF_4L & _ICPRT_OFF_4L & _LVP_OFF_4L & _STVREN_OFF_4L
        __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L
        __CONFIG _CONFIG5H, _CPB_OFF_5H
        __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L
        __CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H & _WRTD_OFF_6H
        __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L

    Thanks.
    post edited by fandudu - 2006/06/06 07:09:41
    #7
    jtemples
    Super Member
    • Total Posts : 11007
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 09:18:56 (permalink)
    0
    ORIGINAL: jc_lim3

    how does brown out reset prevent or avoid unwanted writes?

    If you allow the PIC to go into brownout, your EEPROM write code may randomly execute with random values.
    #8
    Guest
    Super Member
    • Total Posts : 80500
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 09:58:05 (permalink)
    0
    Then how to protect the PIC from brownout?
     
    In addition, my program does not run EEPROM write every time when it is started. It first checks user input, then decide to run READ or WRITE of EEPROM. I have a LCD display showing me if it reads from or write to EEPROM.  And the program runs correct logicly. But sometime the data read from EEPROM are all 0xFF, which means the data writen to EEPROM were lost or overwritten. This happens sevral times in last month.
     
    Is it beecause of brownnout pretection or EEPROM program problem? Thanks.
    post edited by fandudu - 2006/06/06 10:41:31
    #9
    jspaarg
    Super Member
    • Total Posts : 2926
    • Reward points : 0
    • Joined: 2005/05/25 16:47:08
    • Location: PA, now MN via NJ,AZ,OR,CA
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 10:46:40 (permalink)
    0
    Generally speaking, a brownout will only affect a single location of EEPROM.  That said however, I have seen cases where multiple bytes are corrupted if the PIC runs at low voltages (BOR is not enabled).
     
    It is standard practice to either checksum or CRC data stored in EEPROM for fault detection; or to save multiple copies for fault recovery.
     
    My preference is to keep three copies of each critical data item and vote each initialization cycle.
    Non-critical data is either two copies, checksum, or no check.
    If you don't have enough EEPROM for that, then you need to consider CRC or checksum.
     

    PM personal questions and observations only. Keep technical questions to the forums where everyone can benefit.
    When it comes to binary, there are 10 kinds of people: those who understand, and those who don't.
    #10
    jtemples
    Super Member
    • Total Posts : 11007
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/06 10:53:16 (permalink)
    0
    ORIGINAL: fandudu

    Then how to protect the PIC from brownout?

    In addition, my program does not run EEPROM write every time when it is started. It first checks user input, then decide to run READ or WRITE of EEPROM. I have a LCD display showing me if it reads from or write to EEPROM. And the program runs correct logicly. But sometime the data read from EEPROM are all 0xFF, which means the data writen to EEPROM were lost or overwritten. This happens sevral times in last month.

    It's not a matter of brownout occurring during an EEPROM write. During a brownout, the PC (and any other RAM location) can take on a random value. Murphy's law says that the most likely random value the PC will take is somewhere near the beginning of your EEPROM write code. So a random EEPROM write occurs with a random value of EEADR and EEDATA.
    #11
    DINAELEC
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2003/11/07 12:51:59
    • Status: offline
    RE: Why data lost from EEPROM (18F4550) 2006/06/07 02:09:36 (permalink)
    0
    dear fandudu
     
       i m useing 18f8720. i already used  graphical disply ,serial eeprom , intrenal eeprom.but i didn't faced any problem , 
     
    if u feel that it happen due to BOR problem why don't temperary check after  disable it..  
    i think u have problem in eeprom write or read code..
    if u send code it is easy to understand..
    #12
    Guest
    Super Member
    • Total Posts : 80500
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Why data lost from EEPROM (18F4550) 2006/06/12 14:23:47 (permalink)
    0
    Here is my code of EEPROM read and write:
     
    ;-------------------------------------------
    ;Write data to EEPROM
    ; par0 : EEPROM address
    ; par1 : DATA to be written
    EEwrite macro par0, par1
      movff par1, EEDATA
      movlw par0
      call EROMWRITE 
      endm
     
    ;Read data from EEPROM
    ; par0 : EEPROM address
    ; par1 : DATA variable to be saved
    EEread macro par0, par1
      movlw par0
      call EROMREAD
      movwf par1
      endm
     
    ;-------------------------------------------
    ;EEPROM calling function
    EROMWRITE:
      movwf EEADR    ; Lower bits of Data Memory Address to write
    ;  movff DATA_EE_DATA,EEDATA ; Data Memory Value to write
      bcf  EECON1, EEPGD  ; Point to DATA memory
      bcf  EECON1, CFGS  ; Access EEPROM
      bsf  EECON1, WREN  ; Enable writes      
      bcf  INTCON, GIE   ; Disable Interrupts
      MOVLW 0x55
      MOVWF EECON2    ; Write 55h
      MOVLW 0xAA    ;
      MOVWF EECON2    ; Write 0AAh
      BSF  EECON1, WR   ; Set WR bit to begin write
      BTFSC EECON1, WR   ; Wait for write to complete
      BRA  $-2
      BCF  EECON1, WREN  ; Disable writes on write complete (EEIF set)
      BSF  INTCON, GIE   ; Enable Interrupts
      return
     
    EROMREAD:
      movwf EEADR    ; Lower bits of Data Memory Address to read
      bcf  EECON1, EEPGD   ; Point to DATA memory
      bcf  EECON1, CFGS   ; Access EEPROM
      bsf  EECON1, RD   ; EEPROM Read
      movf EEDATA, W   ; W = EEDATA
      return

     
    ;-------------------------------------------
    which are called in the program by
     
      EEread 0x00, VBH1
      EEread 0x01, VBL1
     
    or
     
      EEwrite 0x00, VBH1
      EEwrite 0x01, VBL1
     
    where VBH1, VBL1 are defined  variables in the program.
     
    Please check the program. Thanks a lot.
    #13
    Jump to:
    © 2018 APG vNext Commercial Version 4.5