I have been reading this discussion with interest as I have had a similiar problem to yours.
What I tried to do was to write 32 words in a word array to a 24LC256. Initially my micro was the 18F452, but I have moved over to the 18F4680. Both devices gave the same problem. My line of code was:
DATA var WORD [31]
AA var WORD
I2WR var byte
I2ADDR var WORD
I2CWRITE PORTC.4, PORTC.3, I2WR, I2ADDR, [ STR DATA\32 ], I2C_ERR
I would then read the data back as single words:
I2CREAD PORTC.4, PORTC.3, I2RD, I2ADDR, [ AA ], I2C_ERR
When I read the data back, I would repeatedly read some correct data, a bunch of $FFFF, more correct data, then the data would appear to 'move' and would not be at the designated eprom address. All very strange, but whats more it was repeatable within locations of the device.
The device data sheet specifiies that it can read and write a page of 64 bytes, (32 words).
I over came the problem by writing each word in the word array individually, pausing 5 ms between each word write. Not the best solution but it work. This way wastes 160ms of processing time.
I am still trying to find a way to solve my problem as I really need to write the data block in one hit. I might try using the hardware I2C technique next as I2CWRITE ... [ STR DATA\32] didn't work for me.
Paul.




Bookmarks