Pages: [1]   Go Down
Author Topic: I2C eeprom problems  (Read 507 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am trying to read from an eeprom,

http://www.google.si/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCgQFjAA&url=http%3A%2F%2Fwww.melexis.com%2FAsset%2FDatasheet-IR-thermometer-16X4-sensor-array-MLX90620-EEPROM-DownloadLink-6088.aspx&ei=AAK3UOGGIaqR0AWTy4A4&usg=AFQjCNFBlUtGBxEViZIAWJhEoIN4wypLAA&sig2=FEQhqfYZQv7q0aaGKFNT6w

but it seems I am doing something wrong. I am using the following I2C master library

http://homepage.hispeed.ch/peterfleury/group__pfleury__ic2master.html

The code

Code:
// INCLUDES //
#include <i2cmaster.h> // i2c master library

// DEFINITIONS //
#define EEPROM_address 0xA0

// VARIABLES //
word EEPROM_data[256];

// SETUP //
void setup()
{
  Serial.begin(115200); // setup serial communication
  i2c_init(); // initialize I2C master interface
  eepromRead(); // read eeprom  
}

// LOOP //
void loop()
{
  Serial.println("EEPROM data:");
  Serial.println(EEPROM_data[0]);
  delay(1000);
}

// FUNCTIONS //
// read all from eeprom
void eepromRead()
{
  i2c_start_wait(EEPROM_address+I2C_WRITE); // set device address and write mode (0 is write)
  i2c_write(0x00); // write address  
  i2c_rep_start(EEPROM_address+I2C_READ); // set device address and read mode (1 is read)
  
  for(int i=0;i<255;i++) {
    EEPROM_data[i] = i2c_readAck(); // read one byte and request more data
  }
  i2c_stop();  // terminate data transfer and release I2C bus  
}


Can anyone advise me please? If I do not call the eepromRead(); function in setup, I can see the output on the serial monitor ("EEPROM data: 0"). But if I call the eepromRead(); function, the serial output is blank.

Thank you and best regards,
K

Moderator edit: quote tags changed to code tags (Nick Gammon)
« Last Edit: November 29, 2012, 02:18:22 am by Nick Gammon » Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19361
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void loop()
{
  Serial.println("EEPROM data:");
  Serial.println(EEPROM_data[0]);
  delay(1000);
}

But you are only displaying the first byte.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19361
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not use the Wire library? I have stuff here about accessing EEPROMs:

http://www.gammon.com.au/i2c
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear Sirs,

I am a certified idiot. Had the wrong pin configuration. Everything working now.

Thank you for the answer and help.

Best regards,
K
Logged

Pages: [1]   Go Up
Jump to: