The M24M02 EEPROM (2Mbit, so 18 bit address space) includes the top two address bits as part of the device address. Only a 16 bit address is sent as "data".
An ugly way to deal with this would be to register all four of the "device addresses" using i2c_master_bus_add_device() and to write conditional logic to use different device handles according to the memory quadrant when reading/writing.
An alternative would be to call i2c_master_bus_add_device() for each interaction, read/write bytes, and then i2c_master_bus_rm_device().
In my particular case, the read/write is NOT very frequent and will be page-level writes, so I suppose the add + interact + rm approach is OK, but it doesn't feel good. Since the pages will be used sequentially, this approach could be refined to check the memory quadrant each read/write and only remove/add when it changes.
Is there a more elegant approach?
Best way to code for M24M02 I2C EEPROM with memory address in device id
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Bytespider, PetalBot and 8 guests