faulty EEPROM

rwfurness

New Member
I have constructed a refrigerator monitoring system: it monitors 5 temperatures, 2 door openings and electrical energy consumption every minute. All seemed to be working fine until I did a verifacation test of the temperature sensors a few days ago, and got spurious readings. I then ran a program to store zero in every memory location in the 24LC256/P EEPROM, and read the data back again. I was very surprised to find that there were values other than zero in some memory locations. It seems that some EEPROM memory locations are no longer functional. Is this possible? What might be the cause?

Any help gratefully received.

Robert Furness
 

Andrew Cowan

Senior Member
EEPROM has a maximum number of writes it can handle before it dies (either 100,000 or 1,000,000 - can't remember). Could you have exceeded this?

Andrew
 

hippy

Ex-Staff (retired)
As Andrew notes, Eeprom supports only a limited number of writes. In use, testing, or zeroing, write timing and page size requirements have to be met or data may not be correctly written or cleared.

How often was Eeprom being written ? Writing to the same location once a second could destroy that location in 11 days ( assuming 1,000,000 write capability ). Writing to different/ consecutive locations should give a correspondingly longer lifetime.
 

demonicpicaxeguy

Senior Member
a quick test to be sure it's the eeprom and not the circuit and or outside interference,

readout the contents of the eeprom twice and compare results

if the two are identical then write a known value to all the cells and check them,

even though microchip rate the eeprom at 1,000,000 it's not exactly set in stone that they'll failure just after 1,000,000 cycles, i did a test a while ago and got several times that however after reading the notes microchip provide regarding eeprom memory higher numbers shouldn't be a problem if the pic was run at a lower voltage,

providing the above two tests proove the eeprom still works ok, i'd turn my attention to outside interference,
 

westaust55

Moderator
faulty EEPROM ? ?

Might be good if you posted at least your EEPROM clearing program code.

Are you writing the zero’s to EEPROM as single bytes or groups of bytes?

If you are writing multiple bytes at a time you need to page a pause (say 10ms) between each PICAXE write.

Another consideration with multiple bytes is the EEPROM write paging scheme.
EEPROM such as the 24LC256 have a paging system where each page is 64 bytes. If you write a group of zero’s at a time and cross a page boundary, then the EEPORM internal address pointer rolls back to location 0 within the same page. But your next EEPROM write command would store at the correct address again.
 

rwfurness

New Member
thanks for help; still puzzled

Many thanks for all the suggestions.

Firstly, I have written to the EEPROM probably about 50 times, so exceeding the maximum number of cycles is not an issue.

After running the test program (code below) most memory locations did in fact have '0' in them, but some had other numbers (sometimes '255', but not always). After running the program a number of times, some errors seemed to always be at the same addresses, but I am not sure if all were.

The test code writes six '0s' in sequence, increments the memory location by 6, and then does the same, repeating endlessly. Data is displayed on an LCD display, and is also uploaded to a PC. Data on LCD and in PC agree. There seem to be adequate pauses in the program.

init: pause 500 'initialisation of LCD
serout 6, n2400, (254, 1) 'blank LCD
pause 30 'blanking pause
i2cslave %10100000, i2cfast, i2cword 'configure for 24LC2256
w7 = 0 'EEPROM address = 0
eewrite: writei2c w7, (0,0,0,0,0,0)
pause 1000

eeread: readi2c w7, (b0, b1, b2, b3, b4, b5)
pause 1000
serout 6, n2400, (254,128,#b0,#b1,#b2,#b3,#b4,#b5) 'display on LCD

upload2: pause 1000 'pause 0.1 s
serout 5, N1200, (#b0,",",#b1,",",#b2,",",#b3,",",#b4,",",#b5,10,10) 'send data to pc + line feed
pause 100 'pause 0.1 s
w7 = w7 + 6
goto eewrite

Any further help much appreciated.

Robert Furness
 

westaust55

Moderator
EEPROM address paging, as I mentioned previously, will be at least one of the problems, in so far as you are not testing all EEPROM locations with your current program.
Try this code to eliminate the paging problem:

Code:
init:
 pause 500 'initialisation of LCD
serout 6, n2400, (254, 1) 'blank LCD 
pause 30 'blanking pause 
i2cslave %10100000, i2cfast, i2cword 'configure for 24LC2256 
w7 = 0 'EEPROM start address = 0

eewrite: 
writei2c w7, (0,0,0,0,0,0,0,0)
pause 1000  ‘'pause 1.0 sec

eeread: 
readi2c w7, (b0, b1, b2, b3, b4, b5, b6, b7)
pause 1000
serout 6, n2400, (254,128,#b0,#b1,#b2,#b3) 'display on LCD
serout 6, n2400, (254,192,#b4,#b5,#b6,#b7) 'display on LCD

upload2: 
pause 1000 'pause 1.0 sec
serout 5, (N1200,#b0,",",#b1,",",#b2,",",#b3,",",#b4,",",#b5,",",#b6,",",#b7,10,10 ) 'send data to pc + line feed
pause 100 'pause 0.1 sec
w7 = w7 + 8
goto eewrite
By using groups of 8 bytes, each 8th test ends at a 64 byte page boundary.

While this solves one problem, in so far as testing ALL EEPROM locations, the program is otherwise right and if you are still seeing non zero values, then it would seem you may have a fault EEPROM.

Out of curiosity, what voltage do are you using?

If the values are not always in the same location, could be worth checking that your two pull up resistors for the i2c clock and data lines are electrically secure – no cold solder joints etc. Same for the three EEPROM address lines - pulled to ground.
 

rwfurness

New Member
supply voltage, etc.

Thanks for the latest suggestions.

The information about the 64 byte page size is particularly useful, as I will modify the main program in light of this.

Supply is from 4 X AA recahargeables, freshly charged - should be about 4.8 V.

Robert
 

hippy

Ex-Staff (retired)
This is my Eeprom test program. It writes a different value to each cell then checks the same is read back. It's slow and isn't entirely necessary in most cases to run all 256 passes. Don't forget to Clear Hardware Memory after use of it will write Eeprom whenever powered up or reset !

Code:
#Picaxe 20X2
#Terminal 9600
#No_Data
#No_Table

Symbol EEPROM_24LC32  = 32
Symbol EEPROM_24LC64  = 64
Symbol EEPROM_24LC128 = 128
Symbol EEPROM_24LC256 = 256
Symbol EEPROM_24LC512 = 512

Symbol EEPROM_TYPE    = EEPROM_24LC256 ' <-- Alter this

Symbol pass           = w0
Symbol adr            = w1
Symbol lsb            = b2
Symbol msb            = b3
Symbol putValue       = b4
Symbol gotValue       = b5
Symbol msbMax         = b6
Symbol msbMsk         = b7
Symbol msbTmp         = b8

I2cSlave $A0, I2cSlow, I2cWord

Pause 2000

adr = EEPROM_TYPE / 8
SerTxd( "Testing 24LC", #EEPROM_TYPE, " ( ", #adr, "K x 8 )" )
If adr < 4 Or adr > 64 Then
  SerTxd( " - Cannot test", CR, LF )
  End
End If

msbMax = EEPROM_TYPE / 2 - 1
msbMsk = msbMax / 64

For pass = 1 To 256

  SerTxd( CR, LF, "Writing, Pass ", #pass, CR, LF )

  For msb = $00 To msbMax
    msbTmp = msb & msbMsk
    If msbTmp = 0 Then
      SerTxd( "." )
    End If
    For lsb = $00 To $FF
      putValue = msb + lsb + pass
      I2cWrite adr, (putValue)
      Pause 5
    Next
  Next

  SerTxd( CR, LF, "Checking", CR, LF )

  For msb = $00 To msbMax
    msbTmp = msb & msbMsk
    If msbTmp = 0 Then
      SerTxd( "." )
    End If
    For lsb = $00 To $FF
      putValue = msb + lsb + pass
      I2cRead adr, (gotValue)
      If gotValue <> putValue Then
        SerTxd( CR, LF, "Failed, Got ", #gotValue, ", Expected ",#putValue )
        Pause 1000
      End If
    Next
  Next

  SerTxd( CR, LF, "Done" )

Next

SerTxd( CR, LF, "All passes completed" )
 

rwfurness

New Member
thanks for help

Thanks Hippy for the EEPROM test program. I do admire the well structureed programming - mine is not as good as that. I did not quite follow all of it, so I will have to look at it in more detail.

One aspect - I was not sure what the items at the start of the program preceded by the '#' signs were for.

Dippy: yes, I will have to get some spare EEPROMs. A good idea. But I had not expected to find faults with my one.

Cheers

Robert
 

MPep

Senior Member
The # instructions are commands for the Editor, to set up to use a 28X2 etc.
Listed in Manual2.
 

westaust55

Moderator
The first few lines with the # symbol at the front are called directives.


They are not part of the actual PICAXE program, but are commands to the PICAXE Programming Editor to
- define which PICAXE chip is being used,
- - open the terminal window and pre-define the comms baud rate
- Not to download / clear the EEPROM data area, and
- Not to download/clear the table memory area

See PICAXE Manual 2 (V6.9) page 7 for more details on directives.
 

Dippy

Moderator
Robert, it's always a good idea to get spares (assuming not a ridiculous cost).

All of us Old hacks have had duffers or popped things in the past. And the extra postage cost/delays waiting for another bit far outweighs the few quid for some spares.
 
Top