I2C with EEPROM is not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

I2C with EEPROM is not working

1,682 次查看
Guy_mego
Contributor II

Hi fellows,

I'm using LPC1765 MCU, I have an external AT24C16 EEPROM. I configure an I2C that can write and read data from the EEPROM. The issue is that when I'm trying to write data or read the first thing that I need to do is to write data with the slave address, and the CMSIS is implemented with bitwise of <<1 to the slave address.

On my board the SCL in on (0,28) port and the SDA on (,27) port.

Can anyone can clarify how to solve this issue.

Thanks in advance.

0 项奖励
回复
4 回复数

1,629 次查看
Guy_mego
Contributor II

Hi Alex,
I do send the slave address using the function I2C_MasterTrasferData(I2C, &trasnfer_M_Cnf, I2C_TRASFER_POOLING); 
when the struct of trasnfer_M_Cnf is with the slave address of 0xA0.
when I debug I2C_MasterTrasferData function under lpc17xx_i2c.c in line 825 when the function is calling to I2C_SendByte the CodeStatus I receive is always 0x20.

I'm trying to understand, why when I'm tying to send byte to slave I can't do it and receive the CodeStatus 0x20.

Thanks.

0 项奖励
回复

1,624 次查看
Alex_Wang
NXP Employee
NXP Employee

Hi, @Guy_mego 

        I can't find the function "I2C_MasterTrasferData(I2C, &trasnfer_M_Cnf, I2C_TRASFER_POOLING)". What library do you use? I'm using the library functions in LPCopen. See the picture below:

Alex_Wang_0-1708417631050.png

          According to your description, using the I2C_MasterTrasferData(I2C, &trasnfer_M_Cnf, I2C_TRASFER_POOLING) function always returns 0x20, while using I2C_SendByte does not return 0x20? If it is convenient, please send me your project.

Best regards, Alex

0 项奖励
回复

1,618 次查看
Guy_mego
Contributor II

Hi Alex,

I solved the problem.
Per the datasheet of the EEPROM it was not clear the that 0xA0 is the slave address after shifting 1 bit left, and I thought it is before this is the reason I got the 0x20 on the code status.

Anyway thanks for the help.

0 项奖励
回复

1,635 次查看
Alex_Wang
NXP Employee
NXP Employee

Hi, @Guy_mego 

       According to your description, do you want to write or read data without first writing the slave address? This problem is unavoidable because the I2C protocol stipulates that read or write data must be written to the slave address first after the start signal. Read or write slave addresses can be defined by themselves:

// Assume that the address of the EEPROM is 0xA0
uint8_t eeprom_write_address = 0xA0 << 1; // Write operation address
uint8_t eeprom_read_address = (0xA0 << 1) | 0x01; // Read operation address

       If my understanding is wrong, please tell me more details.

Best regards, Alex

0 项奖励
回复