AnsweredAssumed Answered

STM32F0 eeprom issue

Question asked by qasim.qasim on May 19, 2016
Latest reply on May 27, 2016 by NFC software support 3
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

Outcomes