Picaxe 18x and 24LC256

david-vk3jda

New Member
Hi All,
Can any one help with why this stops working above memory address 112?

If you set memmax higher then 112 you get the error led turn on.

This is my first time at using the 24LC256.
I have 4k7 pullup's on sda & scl lines.


Code:
symbol memmin = 1                             'should location 0 work?

symbol memmax = 112                         '112 last working address
                                               '113 and above do not work
symbol memadd = w2


	i2cslave %10100000, i2cfast, i2cword
	high 0
	pause 5000
	low 0
	
start:
	for memadd = memmin to memmax
	b0 = memadd & $FF
	writei2c memadd, (b0)
	next memadd
	

	for memadd = memmin to memmax
	readi2c memadd, (b1)
	b0 = memadd & $FF

	if b1 = b0 then goto ok
	high 0
	pause 1000
	low 0
	
ok:
	next memadd
	goto start

Thanks for any help.
David
 
Last edited:

hippy

Ex-Staff (retired)
You could try with a "PAUSE 20" after the WRITEI2C as you may not be giving the chip enough time to write its data before trying to write more. ou can reduce the PAUSE time once you have it working.

I'm not sure why the program fails at 113. It could be failing before then, but data written to Eeprom in previous tests may make it appear to be working beyond where it is now failing.

When testing read and write to Eeprom it is best to have two loops, the first writes one sequence of values and checks those, then the second writes a different sequence of values over the first and checks them. That way you are sure you aren't reading values written in previous experiments and think the test is working when it actually isn't.
 

womai

Senior Member
You are definitely missing a "pause 20" after your write command. EEPROMS aren't very fast when writing (reading is fast though). Many EEPROMS include a buffer of limited size, so you can write several bytes at once, but if you keep writing more and more, at some point in time the buffer will run full and you'll lose data. Typical buffer size ranges from 16 to 128 bytes.

According to the Microchip data sheet the 24LC256 has only a 64 byte buffer, so that may explain the behavior that you see.

Wolfgang
 
Top