cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 eeprom issue

embedsol
Associate II
Posted on May 19, 2016 at 12:58

hello

i am using stm32f03 to interface with eeprom but i am unable to read data please provide help on this 

my code is attatched

void I2C_WrReg(uint8_t Reg, uint8_t Dat)

{

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_BUSY) == SET);

I2C_TransferHandling(EEPROM_I2C, EEPROM_ADDRESS_RD, 1, I2C_Reload_Mode, I2C_Generate_Start_Write);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_TXIS) == RESET);

I2C_SendData(EEPROM_I2C, Reg);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_TCR) == RESET);

I2C_TransferHandling(EEPROM_I2C, EEPROM_ADDRESS_RD, 1, I2C_AutoEnd_Mode, I2C_No_StartStop);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_TXIS) == RESET);

I2C_SendData(EEPROM_I2C, Dat);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_STOPF) == RESET);

I2C_ClearFlag(EEPROM_I2C, I2C_FLAG_STOPF);

}

uint8_t I2C_RdReg(uint8_t Reg)

{

uint8_t Dat;

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_BUSY) == SET);

I2C_TransferHandling(EEPROM_I2C, EEPROM_ADDRESS_RD, 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_TXIS) == RESET);

I2C_SendData(EEPROM_I2C, Reg);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_TC) == RESET);

I2C_TransferHandling(EEPROM_I2C, EEPROM_ADDRESS_RD, 1, I2C_AutoEnd_Mode, I2C_Generate_Start_Read);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_RXNE) == RESET);

Dat = I2C_ReceiveData(EEPROM_I2C);

while(I2C_GetFlagStatus(EEPROM_I2C, I2C_FLAG_STOPF) == RESET);

I2C_ClearFlag(EEPROM_I2C, I2C_FLAG_STOPF);

return Dat;

}

A0 is write address

A1 is read address

1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee
Posted on May 27, 2016 at 13:50

Hello qasim,

What do you mean by A0 is write address, A1 is read address?

For the M24LR, device address is A6 for data area write (A7 for read) and AE to write config register (AF to read), you can refer to the datasheet of the M24LR for that.

http://www.st.com/content/st_com/en/products/memories/nfc-rfid-memories-and-transceivers/dynamic-nfc-rfid-tags/m24lr-series/m24lr04e-r.html

Hope this will help you.

Kind Regards.

View solution in original post

1 REPLY 1
Rene Lenerve
ST Employee
Posted on May 27, 2016 at 13:50

Hello qasim,

What do you mean by A0 is write address, A1 is read address?

For the M24LR, device address is A6 for data area write (A7 for read) and AE to write config register (AF to read), you can refer to the datasheet of the M24LR for that.

http://www.st.com/content/st_com/en/products/memories/nfc-rfid-memories-and-transceivers/dynamic-nfc-rfid-tags/m24lr-series/m24lr04e-r.html

Hope this will help you.

Kind Regards.