I2C.bsp demo question
john_s
Posts: 369
in BASIC Stamp
While working with 24LC256 I decided to try I2C.bsp demo program from BASIC Stamp Syntax and Reference Manual 2.2 (pages 222-223 and 229-230). However, it immediately failed on I2CIN command when trying to read from the very first addr = 0.
After changing few lines and adding extra variables addr.HIGBYTE and addr.LOWBYTE (instead of just addr inside both I2COUT and I2CIN) it started reading correctly ... but then stopped again with I2CIN error at address 256.
I'm still puzzled why...?
After changing few lines and adding extra variables addr.HIGBYTE and addr.LOWBYTE (instead of just addr inside both I2COUT and I2CIN) it started reading correctly ... but then stopped again with I2CIN error at address 256.
I'm still puzzled why...?
Comments
Apparently 24LC16 is a bit tricky and different from the other bigger 24LSxx EEPROMs.
24LC16 is organized as 8 blocks of 256 bytes each and that requires a different addressing approach.
My guess is that after correct reading the first 255 bytes of the first "block" the attempt to read from the second "block" fails to address since the 24LS256 has none of this.
Simple fix is to comment ' block = addr.NIB2 << 1 in both write and read lines.
After these adjustments the I2C.bsp demo works as expected...
Took me a while to notice the difference... Great help, thanks!