Thursday, October 20, 2011

Task 38a - using the I2C bus with an EEPROM 24LC64 addressed differently

I've added a line to the earlier code coz i want to make it easier to change the device address.


 In this particular case:
  A0 is LOW;
  A1 is HIGH;
  A2 is LOW.


This device needs to be addressed as 0x52
(see code changes below)


#include {Wire.h}           // I2C library - usual brackets warning

byte  LCaddress  = 0x52;    // 24LC64 device address
:
:
// now write the char-string to the EEPROM - NOTE 0x52:address pin A1 is HIGH
i2c_eeprom_write_page(LCaddress, 0, (byte *)somedata, sizeof(somedata));
:
:
// now access the first address (0) from the memory
 byte b = i2c_eeprom_read_byte(LCaddress, 0);   //NOTE 0x52:address pin A1 is HIGH
:
:
 addr++;                //..next address &..
//..access next address from the memory.
b = i2c_eeprom_read_byte(LCaddress, addr);      //NOTE 0x52:address pin A1 is HIGH
:
:
etcetera..

& i've changed the input data just to make sure the program's doing what it should be doing..
 
char somedata[] = "Jane-Maree's EEPROM data";  // - 24 characters..



And this is what it does..










..& when i've written..

byte  LCaddress  = 0x51;    // 24LC64 device address


 ..it's because.. 

  A0 is HIGH;
  A1 is LOW;
  A2 is LOW.


..& this device needs to be addressed as 0x51..



..producing this  ==} 




i've got pikkies of the breadboard arrangement clearly (i hope) showing the connections to A0, A1, & A2.


Everything else is unchanged..







1 comment:

  1. if i were to address the device in Binary, it might be a little clearer..

    i might try that.

    there are rules about addressing these I2C devices, concerning the values of the first & second Nybbles of the address Byte.

    it's the second Nybble that we change to address different device on the SAME I2C bus!

    if i had a second device, i could show that via the Serial Monitor.

    ReplyDelete