2016-05-19 03:58 AM
hello
i am using stm32f03 to interface with eeprom but i am unable to read data please provide help on this my code is attatchedvoid 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 addressA1 is read addressSolved! Go to Solution.
2016-05-27 04:50 AM
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. Hope this will help you. Kind Regards.2016-05-27 04:50 AM
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. Hope this will help you. Kind Regards.