I2C.bsp demo question

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 searching and reading the data sheets I hope I found the answer...

    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...

  • The 24LC256 uses Big Endian mode for its address -- this may be causing a problem, too.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Jon, to prove the point I used bsp programs that you wrote for different EE's in the past.
    Took me a while to notice the difference... Great help, thanks!
Sign In or Register to comment.