Hello,
For an appplication i need an external memory to store some data.
Therefore i will use an Eeprom from microchip, type 24AA16, which can be written and read by using the I2C protocol.
In a program i try to write data to different locations of the memory (Eeprom) (8 levels possible, selected by bit 1, 2 and 3 of the controlbyte).
This is done by using some lookup tables.
As a test i will read back the complete memory and write it to hyperterminal (using serout).
Well, as you can imagine this is going wrong. I think the problem has to be something to do with the I2CRead instruction.
Reading the datasheet i found some rules.
- The controlbyte has the format 1010ABCx. A, B and C are selectionbits for the level (block) of the memory (8 blocks of 256 byte available). x is used for write or read action (will be controlled by the I2CWrite and I2CRead instructions).
- The I2C write sequense seems to be the same as used in the I2CWrite instruction (see image 1, byte write)
- The I2C read sequence is different and i think the problem can be found here. For random reading (this is what i want to use) the internal Eeprom addresscounter must be set first. This is done with a write instruction. Then - without a stop - a read instruction is folowing to get the data. (see image 2, random read)
So, it seems to me that i have to write a special routine for reading out the Eeprom by using the lower level I2C instructions.
I tried to do this, but do not know how to handle the acknowledge bit in case of reading out one byte per instruction.
In the sourcecode below, i've tried to use the normal I2CRead instruction, but that doesn't work. Also the readout of the Eeprom is attached as txt-file.
Hopefully someone has some experiance with this type of Eeprom...
For an appplication i need an external memory to store some data.
Therefore i will use an Eeprom from microchip, type 24AA16, which can be written and read by using the I2C protocol.
In a program i try to write data to different locations of the memory (Eeprom) (8 levels possible, selected by bit 1, 2 and 3 of the controlbyte).
This is done by using some lookup tables.
As a test i will read back the complete memory and write it to hyperterminal (using serout).
Well, as you can imagine this is going wrong. I think the problem has to be something to do with the I2CRead instruction.
Reading the datasheet i found some rules.
- The controlbyte has the format 1010ABCx. A, B and C are selectionbits for the level (block) of the memory (8 blocks of 256 byte available). x is used for write or read action (will be controlled by the I2CWrite and I2CRead instructions).
- The I2C write sequense seems to be the same as used in the I2CWrite instruction (see image 1, byte write)
- The I2C read sequence is different and i think the problem can be found here. For random reading (this is what i want to use) the internal Eeprom addresscounter must be set first. This is done with a write instruction. Then - without a stop - a read instruction is folowing to get the data. (see image 2, random read)
So, it seems to me that i have to write a special routine for reading out the Eeprom by using the lower level I2C instructions.
I tried to do this, but do not know how to handle the acknowledge bit in case of reading out one byte per instruction.
In the sourcecode below, i've tried to use the normal I2CRead instruction, but that doesn't work. Also the readout of the Eeprom is attached as txt-file.
Hopefully someone has some experiance with this type of Eeprom...