EEPROM Read errors in 16F876

Author
Mark_H
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2007/01/17 06:13:53
  • Location: United Kingdom
  • Status: offline
2007/02/27 05:39:18 (permalink)
0

EEPROM Read errors in 16F876

Hi there,
 
I am having problems with an intermittent problem with 16F876 EEPROM Read, I have run through a whole series of tests and the core problem can best be illustrated by :
 
Program device including test code code into EEPROM.
Read back test code using device programmer, no problem.
 
Use simple read EEPROM loop to self read (USART output) and devices very often check out OK.
 
A much larger programme (3k) consistently reads back the address of the EEPROM byte as the data value (no noise no dropouts, just a straight echo).
   Checked input output loops with dummy data not from EEPROM = OK.
   Written EEPROM read in C and directly in Assembler Exactly as in data sheet - same problem.
 
On occasion devices have worked OK, sometimes consistently so.
 
I have tried different boards on which to run the chips, one board seems more reliable than others (but EEPROM is internal and Input output works fine with test data?).
I have tried different clock frequencies without effect and also padding time between instructions.
I have disabled interrupts (though these were infrequent).
I have got a colleague to try and reproduce the problem and to check the code, no problem with code and problem did not show.
 
What I am looking for is any hints as to what factors can be at play. An EEPROM read is surely timing insensitive?
The 4 chips could all be duds but note that programming reads and writes OK using the programmer and that chip 'self reads' sometimes work OK.
 
Please help as life is getting frustrating here [:@]
 
 

Chipping away with a PIC
#1

15 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 06:46:28 (permalink)
    0
    ORIGINAL: Mark_H

    An EEPROM read is surely timing insensitive?



    Hi, I can almost swear that the answer is yes.

    I had troubles due to mis-decoupling, on a 16F part. It was the "write" going awry. Which is what I suppose in your case also.



    GENOVA :D :D ! GODO
    #2
    Mark_H
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2007/01/17 06:13:53
    • Location: United Kingdom
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 06:52:41 (permalink)
    0
    Dario,
     
    Yes the write has fouled up also, I was concentrating on the read to try and solve the simpler problem first.
     

    Mis-decoupling

     
    I have a 0.1uF ceramic disc capacitor near the chip. Any suggested improvements?
     
    Thanks,
     
    Mark
     
    #3
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 06:59:12 (permalink)
    0
    The 0.1 is ok, the guy who had that problem (in my post) did miss them (how crazy [:@])

    Is VCC stable, within range... (I also put some 22uF)? Spikes, brown-out situations... Interrupt disabled during write?

    Oh, you say "concentrating on the read to try and solve the simpler problem first", but how do you know you have a "read" problem? Could it be just a "write" problem? Or you mean "corruption" after a while?

    GENOVA :D :D ! GODO
    #4
    magio
    Super Member
    • Total Posts : 2164
    • Reward points : 0
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 07:00:37 (permalink)
    0
    ORIGINAL: Mark_H

    I have a 0.1uF ceramic disc capacitor near the chip. Any suggested improvements?



    Yes, enable the brown out detector. 

    Filter the MCLR pin too, this is a good practice.

    Do you have some magnetic interference somewhere?


    Embedded Software and Hardware Development


    #5
    Mark_H
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2007/01/17 06:13:53
    • Location: United Kingdom
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 07:15:53 (permalink)
    0
    Thanks Guys,
     
    I have tried both battery power and mains feed, on reflection the mains feed is better and that board has smoothing capacitors, I will add a 22uF as you suggest and see what happens.
     
    Filter MCLR
    Sounds relevant as the device once worked well and then stopped when I connected a probe to MCLR. What do you have in mind 0.1uF to VSS ? I just have 22kohm to VDD at the moment.
     
    Magnetic interfrence, probably not, presumably we are talking big motors in the vicinity or similar to get that?
     
    Mark
    #6
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 07:52:18 (permalink)
    0
    Yep, 0.1 will do fine, and alo a lower res IMO (4K7 ?)

    GENOVA :D :D ! GODO
    #7
    magio
    Super Member
    • Total Posts : 2164
    • Reward points : 0
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 08:54:30 (permalink)
    0
    ORIGINAL: Mark_H

    Sounds relevant as the device once worked well and then stopped when I connected a probe to MCLR. What do you have in mind 0.1uF to VSS ? I just have 22kohm to VDD at the moment.


    Is too big as Dario already suggested.  A 4k7 or 2k2 will be ok.  .1uF is also fine.

    Don't forget to enable the Brown Out detector.  If power goes down during a read the read operation can become a write.  This is a faq and you can search about it the forum.

    ORIGINAL: Mark_H
    Magnetic interfrence, probably not, presumably we are talking big motors in the vicinity or similar to get that?


    Yes and no.  Magnetic intereference comes from electirc motors because they have a big inductance that produces a magnetic field which makes the motor rotate.  But that's not only the case.

    Any AC power cable produces magnetic interference.  The bigger the current, the bigger the interference. 

    A power cable providing 2 Ampers close to your board can do more harm than a big motor at 5 mts, but that's just a thought.  May be you don't have such problems.

    There are books that cover this subject and I'm not precisely an expert, I just know a few tips.

    I assume that you are not talking about an automotive application... if that's your case, then you should reconsider all your shieldings.



    Embedded Software and Hardware Development


    #8
    assaad
    Super Member
    • Total Posts : 2504
    • Reward points : 0
    • Joined: 2006/03/27 22:51:42
    • Location: Turkey
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 08:58:46 (permalink)
    0
    Hi magio
     
    If power goes down during a read the read operation can become a write.


     
        Please,  could you explain that for me ? infact I have not faced such a problem , so I need some information about that case
     
    Thank you
     
     
    Edit:   In read EEPROM ( internal) I have not faced any problem, but in write EEPROM, incase of power geos down or due to noise  , I had a reset or write garpage to it .

     
    Assaad
    post edited by assaad - 2007/02/27 09:02:03

    S. ASSAAD
    #9
    mford
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2005/02/11 12:03:55
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/27 12:53:47 (permalink)
    0
    Are you clearing bit 7 of EECON1 register as this may power up in an unknown state.  This caused me a hard to diagnose intermittent EEPROM problem on another device. 
    #10
    Mark_H
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2007/01/17 06:13:53
    • Location: United Kingdom
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/28 04:59:05 (permalink)
    0
    Thanks Guys.
     
    The high value of the MCLR pull up resistor was to allow for use of in circuit programming and use of a lower value and a 47uF smoothing capacitor on the battery powered version has helped (I underestimated some switching 'noise').
     
    I have not yet got completely to the bottom of the issue. The EEPGD bit (7) of EECON1 was already taken care of, but it is interesting that mfords experience (on anothger chip) contradicts the data sheet which says that POR always gives a 0.
     
    I will look into using BOD next. However, a move from 16F876 to 16F886 is now on the cards.
     
    What is to choose between the two BOD voltage levels available on the 16F886 when using a 5v supply (always use the higher, near 5v level?). Any pointers to documents on practical guidance on using BOD would be helpful (take it that I have read the data sheet), I am used to a realiable power supply.
     
    Thanks again.

    Chipping away with a PIC
    #11
    magio
    Super Member
    • Total Posts : 2164
    • Reward points : 0
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/28 05:01:38 (permalink)
    0
    assaad no matter how much I look in the forum, I couldnt find the posts where this was discussed. 
    There's was a nice explanation that clarifies the topic.

    If i found it I'll post the link.

    Embedded Software and Hardware Development


    #12
    magio
    Super Member
    • Total Posts : 2164
    • Reward points : 0
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/28 05:04:24 (permalink)
    0
    Mark I always try to use the Higher BOD level, but this of course depends on your app.   If the power is reliable and firm as you say, then use the higher one.

    To use ICSP you could use a diode rather than a big resistor.  There's an schematic in the Microchip's ICSP application note


    Embedded Software and Hardware Development


    #13
    mford
    Junior Member
    • Total Posts : 98
    • Reward points : 0
    • Joined: 2005/02/11 12:03:55
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/28 07:54:02 (permalink)
    0
    EEPGD bit (7) has contradictory information about power up reset state for PIC16F876A.
     
    On the picture of the register over EEPGD it has "R/W-x" which would indicate POR state is unknown but then there is a note "Reads 0’ after a POR; this bit cannot be changed while a write operation is in progress".
     
    The PIC18F1220 has EEPGD as "R/W-x" and I have found the hard way does not come up in a defined state.  It looks like the PIC16F876 non A version does not have the additional note so I would expect it to be undefined on POR.
     
     
    #14
    rmoline
    Super Member
    • Total Posts : 357
    • Reward points : 0
    • Joined: 2004/12/18 05:18:28
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/02/28 08:32:42 (permalink)
    0
    If power goes down during a read the read operation can become a write.


    Assaad, intriguing to me, too, never knew this and wanted to know more. Found a thread:

    http://forum.microchip.com/tm.aspx?m=167867#

    Posts 8 and 11 from JTemples explain how power dips can execute random EEPROM writes, anytime they happen, not just during an EEPROM read.


    Another similar thread, with some excellent added suggestions from Andy_Tuthill in post 6 and from Microchip Support in post 7:

    http://forum.microchip.com/tm.aspx?m=26907&mpage=1&key=&#26907

    Rob
    post edited by rmoline - 2007/02/28 08:35:01
    #15
    Mark_H
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2007/01/17 06:13:53
    • Location: United Kingdom
    • Status: offline
    RE: EEPROM Read errors in 16F876 2007/03/01 07:52:11 (permalink)
    0
    rmoline, thanks, I missed the thread when searching :
     

    Another similar thread, with some excellent added suggestions from Andy_Tuthill in post 6 and from Microchip Support in post 7:

    http://forum.microchip.com/tm.aspx?m=26907&mpage=1&key=&#26907 

     

     
    This thread is one of the best I have seen on the forum and taught me quite few things unrelated to my direct issue.
     
    A comment : Reading the previous posts motivated me to put in a large smoothing capacitor in a battry powered circuit to avoid some noise effects. However, as the circuit is a micropower one, a 47uF capacitor gives about 2 seconds until the power is too low to keep the oscillator going = problems as above thread. I have now downrated the capacitor and will look to impliment some of the above thread.
     
    Thanks all,
     
    Mark
    #16
    Jump to:
    © 2018 APG vNext Commercial Version 4.5