I2C communication with EEPROM-24LC08B

6 posts / 0 new
Last post
mohit3112
Offline
Last seen:10 months 1 week ago
Expert
加入:2014-08-04 13:45
I2C communication with EEPROM-24LC08B

I am trying to interface EEPROM-24LC08B through I2C to DA14580. Writing is happening but while reading , its getting stuck in this line WAIT_FOR_RECEIVED_BYTE(); .Slave address is also correct 0x50 and I checked with both 2K as well as 4.7K pull-up resistors but in any case,its not working. I2C initialisation part is the same as given in eeprom_test.c.
I am pasting my code below-
Main code
#ifdef EEPROM_TEST
i2c_eeprom_init(0x50,I2C_FAST, I2C_7BIT_ADDR, I2C_2BYTES_ADDR);

i2c_eeprom_write_byte(34,85);
read=i2c_eeprom_read_byte(34);
i2c_eeprom_release();
#endif

Read function:
uint8_t i2c_eeprom_read_byte(uint32_t address)
{
/ / i2c_wait_until_eeprom_ready ();
i2c_send_address(address);

//WAIT_WHILE_I2C_FIFO_IS_FULL(); // Wait if Tx FIFO is full
SEND_I2C_COMMAND(0x0100); // Set R/W bit to 1 (read access)
// WAIT_UNTIL_I2C_FIFO_IS_EMPTY(); // Wait until I2C Tx FIFO empty
WAIT_FOR_RECEIVED_BYTE(); // Wait for received data
return (0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get received byte
}

Write function:
void i2c_eeprom_write_byte(uint32_t address, uint8_t wr_data)
{
/ / i2c_wait_until_eeprom_ready ();
i2c_send_address(address);

// WAIT_WHILE_I2C_FIFO_IS_FULL(); // Wait if I2C Tx FIFO is full
SEND_I2C_COMMAND(wr_data & 0xFF); // Send write data
// WAIT_UNTIL_I2C_FIFO_IS_EMPTY(); // Wait until Tx FIFO is empty

WAIT_UNTIL_NO_MASTER_ACTIVITY(); // wait until no master activity
}

Device:
summer20100514
Offline
Last seen:4年5个月ago
Guru
加入:2014-12-30 05:01
Why do you comment these

Why do you comment these lines in the driver you posted here? The Dialog official driver for eeprom seems working well without any modifications.

kenneth.er
Offline
Last seen:4 years 10 months ago
加入:2015-09-03 15:31
Have you double check the I2C

Have you double check the I2C bus on an oscilloscope if the eeprom truly did ACK your write request? If not mistaken, the write is non-blocking, so the code will execute through even if there's NACK.
Also noticed on your code that you commented the i2c_wait_until_eeprom_ready(). If your eeprom is not responding, this goes into an infinite loop. I would recommend that you try that out first with an oscilloscope if possible.

ops
Offline
Last seen:1 year 3 weeks ago
加入:2016-01-04 09:20
I have the (almost) same

I have the (almost) same problem with i2c EEPROM sample code. I use AT24C32 EEPROM. And the wire is nothing special: P0_2 and P0_3 for SCL and SDA.
At first, the sample code (SDK 5.0.3) always stuck when it write data to EEPROM. I try to change some parameters (size, page, address mode, address size, ...), but nothing work.
This AT24C32 EEPROM is working fine on the other development boards (Arduino Uno, M0 pro).
After few days of hard work (tries), something strange happens. By accident, the terminal (Tera Term) disconnect from the development board (kit).
Then I start the sample code and it success to run without stuck!
Of course, I see nothing on terminal. But put this AT24C32 to Arduino Uno, I can see the content of EEPROM was successfully written by DA14580!
So, I realized that there are conflicts between UART and I2C in wire. Go back to check manual, and yes, P0_2 and P0_3 was indeed connect to build-in FTDI chip's RTS and CTS.
For my development kit (Export, not Pro or Basic), just remove jumpers of J26. Then the sample code work.
I also try some other EEPROM chips, like Microchip 24AA02 and ON Semi 24512. Just change some parameters (size, page, address size, ...), then the code work.

ajay98
Offline
Last seen:2 months 2 weeks ago
加入:2018-07-10 12:12
hi,

hi,

i am also facing same problem with EEPROM MR24M01.i want to write bond data in EEPROM.

eeprom_read_byte() ,

i2c_wait_until_eeprom_ready() is getting error,debug has been stopping. I2C parameters have been corrected properly.

Attachment:
PM_Dialog
Offline
Last seen:10小时54英里n ago
工作人员
加入:2018-02-08 11:03
Hi ajay98,

Hi ajay98,

As mentioned in a previous question that you raised in another forum thread, the i2c_wait_until_eeprom_ready() is polling the device via sending a 0x08 byte until the device responds with an ACK. In addition, MR24M01 is not supported be i2c_eeprom driver. Please check i2c_eeprom.h header file in the SDK. You will need to refer to MR24M01 datasheet and add the appropriate configurations.

If you have any follow up question, please create a new forum thread as this one is old and closed,

Thanks, PM_Dialog