Hello,
I am trying to read from an eeprom,
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
// 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)