Page 1 of 1

I2C EEPROM

Posted: Sat Sep 27, 2008 7:27 pm
by jeffg
Hello,

I did test the example program downloaded on the Matrix website and it did work.

But, in order to well understand what is done and how to use it in my programs. In the example we write 2 values "H" or 72 and "i" or 105:
- but are they store in 0,0 and 0,1 ?
- is it possible to store more than 2 values by each command ?
- is it also possible to read more than 2 values by each command ?

Thanks for your help,

Jeff

Re: I2C EEPROM

Posted: Mon Sep 29, 2008 8:55 am
by Steve
In the I2C program, the commands to set the EEPROM values (at addresses 0 and 1) to "Hi" are:
  • Send <start>
    Send device address
    Send Internal address 1 (0)
    Send internal address 2 (0)
    Send 'H'
    Send 'i'
    Send <stop>
Once you have send the internal addresses, you can continue to write data which will be stored in subsequent locations (the EEPOM itself auto-increments its own internal address pointer after each data write command).

Reading works in a similar way, but with this implementation in Flowcode you need to specify whether or not the call to "I2C_Receive_Byte" is expecting to receive the last byte or not.

There should be more info in the datasheet for the EEPROM itself.

Re: I2C EEPROM

Posted: Mon Sep 29, 2008 9:17 am
by Mark
Hi,

Each EEPROM has a different buffer size, the smaller ones are about 16 bytes, the larger about 64 bytes. The problem being that writing the, say 17th byte, rolls the write around back to 0. Hence, unless your programme is in need of speed (where you could use the 1MHz clock speed versions) then I usually wite each address before every write. Otherwise you have to keep track of how many bytes are written.

Also, I think a write does not acually start until the last write byte is put in the buffer before it is closed, hence, it could be possible to end data storage but without actaully ever writing any data, or to try and read back data not already written. Hence, it is easier to write address and data values singly (in my view).

Regards,

Mark

Re: I2C EEPROM

Posted: Tue Sep 30, 2008 11:28 am
by Benj
Hello

I have updated the example file to add more comments and definitions. Hopefully it is now more understandable.

http://www.matrixmultimedia.com/Downloa ... .php?id=39

Re: I2C EEPROM

Posted: Tue Oct 28, 2008 6:20 pm
by jeffg
Thanks for your explanations but how to do if I want to save 3 values or more ?

Re: I2C EEPROM

Posted: Wed Oct 29, 2008 10:32 am
by Benj
Hello Jeff

If you want to save up to 32 values at once then you will have to do the following.

I2C Start
I2C Send address with 0 read/write bit
I2C Send the two byte initial data address
I2C Send the first data byte
...
I2C Send the nth data byte
I2C Stop

Hope this helps.