So you have a 24C02 and a 24C04.
Right, I'm quite sure of that now. Thank s for confirming the fact.
Let's start with the 24C02. Take a look at the datasheet, it has a "MODE" pin for Multibyte (4 bytes) or page select (8 bytes) to write more bytes.
But if you read and write single bytes, you don't have to use that.
It uses a single byte for the register address of 0...255.
From the datasheet link you sent me I can read §5.1.1 and §5.1.2 it is possible to write byte by byte or by pages up to 16 Bytes !
What I understand from the datasheet is that there is no difference between writting by Byte or writting by Pages till 16 Bytes. What makes the difference is whether or not, the master send the Stop condition after the ACK condition of the last Data (see figure 5 on datasheet)
For instance :
if the Byte address is 0000 0000, I can write up to 16 Bytes of data. Data1 will be written at block address 0000 0000, Data2 at block address 0000 0001......Data 16 at block address 0000 1111. Must end with the Stop condition after the last ACK condition.
If the Byte address is 0000 0100, I can write up to only 12 Bytes of data. Data1 will be written at block address 0000 0100, Data2 at block address 0000 0101......Data 12 at block address 0000 1111. Must end with the Stop condition after the last ACK condition.
if the Byte address is 0000 0100, I can write up to 12 Bytes of data, but I can also write only 1 or 2 data. Data1 will be written at block address 0000 0100, Data2 at block address 0000 0101 and I end with a Stop condition.
So I don't see any "MODE" pin.
Am I right ?
I'm sorry to say, but I'm not happy with your code.
Could you show a function to read a single byte and a function to write a single byte. So I can comment on that.
You don't have to feel sorry, just say it. I'm beginner and am ready to ear all kind of constructive criticism.
As I said somewhere, I'm new at coding and have specific difficulties with the I2C library to understand what I'm doing. In fact till now, I've been copying piece of code found in different places.
The 24C04 has twice the memory. You can read the datasheet how they did that.
The register address is still with a single byte, but the I2C device address selects the missing address bit.
It's a dirty trick, it seems as if there are two I2C devices, each with 256 byte.
Sorry I didn't find anything concerning how "they did that"