PDA

View Full Version : 24lc256 woes



BarryP
31-01-2006, 08:49
Hi Folks.
I have a small excell sheet that creates code to dump data into a 24lc256 for lookup purposes.

Having some problems with Bad Writes.
There are a number of other devices on the i2c bus that don't appear to have any problems.
I have tried just an 18X & lc256 (with appropriate pullups) on a breadboard , and get the same results.

Could some nice sole test this code on their hardware ..

;Write EEprom Data
;18X

i2cslave %10100000 ,i2cslow ,i2cword
'goto Test
Symbol WriteDelay = 10
Symbol FirstMemLocation = 0
Symbol LastMemLocation = 457

'Combined Symbol & CodeString
Symbol s_Word = 0 : WriteI2C s_Word , ( "Word",0) : Pause WriteDelay
Symbol s_UP = 5 : WriteI2C s_UP , ( "UP",0) : Pause WriteDelay
Symbol s_Unitcode = 8 : WriteI2C s_Unitcode , ( "Unitcode",0) : Pause WriteDelay
Symbol s_Transmitting = 17 : WriteI2C s_Transmitting , ( "Transmitting",0) : Pause WriteDelay
Symbol s_Time = 30 : WriteI2C s_Time , ( "Time",0) : Pause WriteDelay
Symbol s_Text = 35 : WriteI2C s_Text , ( "Text",0) : Pause WriteDelay
Symbol s_Test = 40 : WriteI2C s_Test , ( "Test",0) : Pause WriteDelay
Symbol s_Signal = 45 : WriteI2C s_Signal , ( "Signal",0) : Pause WriteDelay
Symbol s_Serial = 52 : WriteI2C s_Serial , ( "Serial",0) : Pause WriteDelay
Symbol s_Sensor = 59 : WriteI2C s_Sensor , ( "Sensor",0) : Pause WriteDelay
Symbol s_Selection = 66 : WriteI2C s_Selection , ( "Selection",0) : Pause WriteDelay
Symbol s_Selected = 76 : WriteI2C s_Selected , ( "Selected",0) : Pause WriteDelay
Symbol s_Select = 85 : WriteI2C s_Select , ( "Select",0) : Pause WriteDelay
Symbol s_SECU16i = 92 : WriteI2C s_SECU16i , ( "SECU16i",0) : Pause WriteDelay
Symbol s_SECU16 = 100 : WriteI2C s_SECU16 , ( "SECU16",0) : Pause WriteDelay
Symbol s_RS232 = 107 : WriteI2C s_RS232 , ( "RS232",0) : Pause WriteDelay
Symbol s_RIGHT = 113 : WriteI2C s_RIGHT , ( "RIGHT",0) : Pause WriteDelay
Symbol s_RF_ON_ = 119 : WriteI2C s_RF_ON_ , ( "RF=ON ",0) : Pause WriteDelay
Symbol s_RF_OFF = 126 : WriteI2C s_RF_OFF , ( "RF=OFF",0) : Pause WriteDelay
Symbol s_RF_ = 133 : WriteI2C s_RF_ , ( "RF=",0) : Pause WriteDelay
Symbol s_Receiving = 137 : WriteI2C s_Receiving , ( "Receiving",0) : Pause WriteDelay
Symbol s_Previous = 147 : WriteI2C s_Previous , ( "Previous",0) : Pause WriteDelay
Symbol s_Outputs = 156 : WriteI2C s_Outputs , ( "Outputs",0) : Pause WriteDelay
Symbol s_Options = 164 : WriteI2C s_Options , ( "Options",0) : Pause WriteDelay
Symbol s_Option = 172 : WriteI2C s_Option , ( "Option",0) : Pause WriteDelay
Symbol s_OPENING = 179 : WriteI2C s_OPENING , ( "OPENING",0) : Pause WriteDelay
Symbol s_OPEN = 187 : WriteI2C s_OPEN , ( "OPEN",0) : Pause WriteDelay
Symbol s_ON = 192 : WriteI2C s_ON , ( "ON",0) : Pause WriteDelay
Symbol s_OFF = 195 : WriteI2C s_OFF , ( "OFF",0) : Pause WriteDelay
Symbol s_New = 199 : WriteI2C s_New , ( "New",0) : Pause WriteDelay
Symbol s_Module_ID = 203 : WriteI2C s_Module_ID , ( "Module ID",0) : Pause WriteDelay
Symbol s_Menu = 213 : WriteI2C s_Menu , ( "Menu",0) : Pause WriteDelay
Symbol s_Maxi_V1_xx = 218 : WriteI2C s_Maxi_V1_xx , ( "Maxi V1.xx",0) : Pause WriteDelay
Symbol s_Light = 229 : WriteI2C s_Light , ( "Light",0) : Pause WriteDelay
Symbol s_LEFT = 235 : WriteI2C s_LEFT , ( "LEFT",0) : Pause WriteDelay
Symbol s_Last = 240 : WriteI2C s_Last , ( "Last",0) : Pause WriteDelay
Symbol s_Lamp = 245 : WriteI2C s_Lamp , ( "Lamp",0) : Pause WriteDelay
Symbol s_IR = 250 : WriteI2C s_IR , ( "IR",0) : Pause WriteDelay
Symbol s_Inputs = 253 : WriteI2C s_Inputs , ( "Inputs",0) : Pause WriteDelay
Symbol s_Infra_Red = 260 : WriteI2C s_Infra_Red , ( "Infra Red",0) : Pause WriteDelay
Symbol s_ID = 270 : WriteI2C s_ID , ( "ID",0) : Pause WriteDelay
Symbol s_Housecode = 273 : WriteI2C s_Housecode , ( "Housecode",0) : Pause WriteDelay
Symbol s_Heater = 283 : WriteI2C s_Heater , ( "Heater",0) : Pause WriteDelay
Symbol s_GATE = 290 : WriteI2C s_GATE , ( "GATE",0) : Pause WriteDelay
Symbol s_Errors = 295 : WriteI2C s_Errors , ( "Errors",0) : Pause WriteDelay
Symbol s_Error = 302 : WriteI2C s_Error , ( "Error",0) : Pause WriteDelay
Symbol s_Err = 308 : WriteI2C s_Err , ( "Err",0) : Pause WriteDelay
Symbol s_DOWN = 312 : WriteI2C s_DOWN , ( "DOWN",0) : Pause WriteDelay
Symbol s_DIM = 317 : WriteI2C s_DIM , ( "DIM",0) : Pause WriteDelay
Symbol s_Delete = 321 : WriteI2C s_Delete , ( "Delete",0) : Pause WriteDelay
Symbol s_Date = 328 : WriteI2C s_Date , ( "Date",0) : Pause WriteDelay
Symbol s_Create_Shortcut = 333 : WriteI2C s_Create_Shortcut , ( "Create Shortcut",0) : Pause WriteDelay
Symbol s_Comm_Port = 349 : WriteI2C s_Comm_Port , ( "Comm Port",0) : Pause WriteDelay
Symbol s_CLOSING = 359 : WriteI2C s_CLOSING , ( "CLOSING",0) : Pause WriteDelay
Symbol s_CLOSED = 367 : WriteI2C s_CLOSED , ( "CLOSED",0) : Pause WriteDelay
Symbol s_Byte = 374 : WriteI2C s_Byte , ( "Byte",0) : Pause WriteDelay
Symbol s_Button = 379 : WriteI2C s_Button , ( "Button",0) : Pause WriteDelay
Symbol s_BRIGHT = 386 : WriteI2C s_BRIGHT , ( "BRIGHT",0) : Pause WriteDelay
Symbol s_Bit = 393 : WriteI2C s_Bit , ( "Bit",0) : Pause WriteDelay
Symbol s_Bazza = 397 : WriteI2C s_Bazza , ( "Bazza",0) : Pause WriteDelay
Symbol s_Baud_Rate = 403 : WriteI2C s_Baud_Rate , ( "Baud Rate",0) : Pause WriteDelay
Symbol s_Analog = 413 : WriteI2C s_Analog , ( "Analog",0) : Pause WriteDelay
Symbol s_All_Units_OFF = 420 : WriteI2C s_All_Units_OFF , ( "All Units OFF",0) : Pause WriteDelay
Symbol s_All_Lights_ON = 434 : WriteI2C s_All_Lights_ON , ( "All Lights ON",0) : Pause WriteDelay
Symbol s_Alarm = 448 : WriteI2C s_Alarm , ( "Alarm",0) : Pause WriteDelay
Symbol s_Add = 454 : WriteI2C s_Add , ( "Add",0) : Pause WriteDelay

Test:
W6 = FirstMemLocation
sertxd ("EEPROM ReadBack",13,10)

Repeat:
pause 10
If W6 = LastMemlocation then AllDone
readi2c w6,(B0)
w6 = w6 + 1
if b0 = 0 then AddCrReturn
if b0 = 255 then ListIndex
sertxd (b0)
goto Repeat
AddCrReturn:
sertxd (13,10)
goto Repeat
ListIndex:
sertxd (13,10,"Error ",#w6,13,10)
goto Repeat
AllDone:
sertxd (13,10,"EEPROM ReadBack Finnished",13,10)
end

Jeremy Leach
31-01-2006, 09:08
Have you tried increasing the write delay in case it's too short (I know it's the standard, but just an idea - especially as you're hammering the i2C device !)

BarryP
31-01-2006, 09:14
The Write delay has no real bearing on the problem.
Most of the errors I get are within the string I am trying To write , not between them.

I.E.
the ....'s are breaks between good data
EEPROM ReadBack
r
rd
UP
.......
Serial
Senso=OFF
ection
Selected
...........
OPEN
uts
FF
.......
Inp
e
OInfra Red
ID
.......
DIMn
elete
Date


Edited by - barryp on 1/31/2006 8:36:12 AM

hippy
31-01-2006, 11:12
Something interesting to note ...

.......
Serial
Senso=OFF
ection
Selected
...........

Looking at the code which is writing the "Senso" and the "=OFF" text ...

- Symbol s_Sensor = 59 : WriteI2C s_Sensor , ( "Sensor",0) : Pause WriteDelay
- Symbol s_RF_OFF = 126 : WriteI2C s_RF_OFF , ( "RF=OFF",0) : Pause WriteDelay

For "Sensor" the "r" is in Eeprom location 64, for "EF=OFF", the "=OFF" starts at Eeprom location 128.

That hints at a 64-byte or 32-word paging issue.

I haven't used I2C for a long time and am not familiar with the device but that observation may be enough to trigger something in someone who is more knowledgeable than me.

My guess is that the data sent is only permanently stored at the end of an I2CWRITE when the chip sees an I2C "stop" condition, the data which exceeds the 64 byte page currently on, overwrites the beginning of the buffer before the write happens. You'd need breaks in your I2CWRITE commands at the end of each 64 byte block.

For example ...

- Symbol s_Sensor = 59 : WriteI2C s_Sensor , ( "Senso") : Pause WriteDelay
- Symbol s_Sensor_1 = 64 : WriteI2C s_Sensor , ( "r",0) : Pause WriteDelay

- Symbol s_RF_OFF = 126 : WriteI2C s_RF_OFF , ( "RF") : Pause WriteDelay
- Symbol s_RF_OFF_1 = 128 : WriteI2C s_RF_OFF , ( "=OFF",0) : Pause WriteDelay

If the Eeprom is buffereing, then you may only need the pause at the end of 64 byte blocks.

You may also need to make sure that the last block used is filled to a 64-byte boundary.

Edited by - hippy on 1/31/2006 10:21:57 AM

Jeremy Leach
31-01-2006, 11:25
I think it could be to do with the page write buffer of the IC. See the i2C tutorial pdf that comes with the PICAXE download. The section on page write buffer. Sorry I don't seem to be able to copy/paste the relevant bit.

I've always written byte by byte for this reason, just to be on the safe side.

Technical
31-01-2006, 11:29
Your issue is definately with the EEPROM page write buffer, your program makes no allowance for it. See the tutorial as Jeremy suggests.

BarryP
31-01-2006, 20:05
Ahhh
The Mist is Lifting ...
The Roll arround effect when page writes exceed the buffer size .............
I'll make some changes & report back this eve.

Thanks For The Guidance

BarryP
01-02-2006, 05:49
Ye Ha
Modified Speadsheet to account for the Buffer Size.
Figured the easiest way was to just not use the last few bytes of the block if it was going to exceed the limit.
So With The Current List of Strings , I wasted 28 bytes.... Certainly don't have a problem with that.

Thankyou All For your assistance.