Il 24c02 ha pagine di 16 Byte;
http://datasheet.sii-ic.com/en/serial_eeprom/S24C01C_02C_E.pdfIl datasheet della Atmel dice che il
24c02 ha pagine da 8Byte e i
24c04 / 24c08 hanno pagine da 16Byte
http://www.atmel.com/Images/doc0180.pdfNon so cosa é giusto per il Tuo EEprom 24c02. Puoi usare un page write di 8 Byte o provare di scrivere 16 byte tutti differenti al indirizzo 0 e leggere cosa é stato memorizzato. Se scrivi 0 0 0 0 0 0 0 0 8 8 8 8 8 8 8 8 e Ti ritrovi con 8 nella cella 0 devi usare page write a 8 Byte.
Se il 24c04 é della Atmel de viusare l' indirizzo I2C per selezionare il blocco della memoria che vuoi indirizzare:
Device Addressing The 1K, 2K, 4K, 8K and 16K EEPROM devices all require an 8-bit device address word
following a start condition to enable the chip for a read or write operation (refer to Figure
7).
The device address word consists of a mandatory one, zero sequence for the first four
most significant bits as shown. This is common to all the EEPROM devices.
The next 3 bits are the A2, A1 and A0 device address bits for the 1K/2K EEPROM.
These 3 bits must compare to their corresponding hard-wired input pins.
The 4K EEPROM only uses the A2 and A1 device address bits with the third bit being a
memory page address bit. The two device address bits must compare to their corresponding
hard-wired input pins. The A0 pin is no connect.
The 8K EEPROM only uses the A2 device address bit with the next 2 bits being for
memory page addressing. The A2 bit must compare to its corresponding hard-wired
input pin. The A1 and A0 pins are no connect.
The 16K does not use any device address bits but instead the 3 bits are used for memory
page addressing. These page addressing bits on the 4K, 8K and 16K devices
should be considered the most significant bits of the data word address which follows.
The A0, A1 and A2 pins are no connect.
L' indirizzo mandato nel comando I2C non sono 2 byte come scrivi Tu nello sketch ma solo 1Byte insieme a seconda della grandezza del EEprom a alcuni byte del indirizzo I2C (vedi sopra)
Per fare un Page write devi:
1) iniziare col indirizzo di partenza a multipli di 8 o rispettivamente 16
2) trasferire 8 o rispettivamente 16 byte di dati.
Se non rispetti l' indirizzo a multipli della grandeza della pagina i dati sopra la grandezza della pagina vengono non scritti sulla pagina sucessiva ma all indirizzo della stessa pagina.
Esempi:
Usi un 24c02: se vuoi scrivere dati sulla seconda pagina:
indirizzo da 0x08 a 0x0f
8 Byte di dati che vengono scritti nelle memorie da 0x08 a 0x0f
Se per esempio parti dal indirizzo 0x0a i 8 byte di dati verranno scritto nelle celle
0x0a a 0x0f e i restanti da 0x08 a 0x09.
puoi comunque iniziare in mezzo an una pagina e scriver dati fine alla fine di quella pagina.
nel precedente esempio sarebbe:
indirrizzo 0x0a e 6 byte di dati che saranno memorizzati nelle celle 0x0a a 0x0f.
Ciao Uwe