Monday 10 December 2012

24LC16 addresses for i2c testing

Puzzled myself when using a 24LC16 as a way of testing i2c operation.

The idea was to put one of these chips on a board so that my i2c Master chip could try writing and saving locally to the 24LC16 and contrast this with the result of trying to write and read to other Picaxe chips acting as Slaves elsewhere on the network. I've found i2c to be a bit temperamental when testing on breadboards (and have two or three 20x2's which work fine except for i2c)

What confused me was the addressing of the 24LC16. It IS NOT the same as for a 24LC256.

Both chips have a default address of 160 (1010 0000), and three pins (A0, A1 and A2) for addressing.

But that is as far as the commonality goes.

For the 24LC256, the setting for the three bits  - A0, A1 and A2 - determines the address of the chip above 160. So set A1 to high and the address becomes 164. The unit won't answer to 160 or any of the other possible values.

But for the 24LC16 the datasheet has an enigmatic phrase that I didn't really understand:


It should be noted that the
protocol limits the size of the memory to eight blocks
of 256 words, therefore, the protocol can support only
one 24XX16 per system.


This seems to mean that on the 24LC16 - the chip will answer for EACH of the eight addresses 160 to 174 inclusive (in two's - Picaxe addresses for i2c are always even). It is as if it is an array of eight 2Kb memory chips, at each consecutive even-numbered address from 160 to 174.