I2C EEPROM

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
jeffg
Posts: 5
Joined: Sat Sep 27, 2008 7:22 pm
Contact:

I2C EEPROM

Post 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

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: I2C EEPROM

Post 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.

Mark
Posts: 209
Joined: Thu Oct 19, 2006 11:46 am
Location: Bakewell, UK
Has thanked: 20 times
Been thanked: 16 times
Contact:

Re: I2C EEPROM

Post 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
Go with the Flow.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C EEPROM

Post 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

jeffg
Posts: 5
Joined: Sat Sep 27, 2008 7:22 pm
Contact:

Re: I2C EEPROM

Post by jeffg »

Thanks for your explanations but how to do if I want to save 3 values or more ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: I2C EEPROM

Post 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.

Post Reply