2021-06-05 12:53 AM
I use stm31f0 micro controller & 24c64 eeprom for store data but unfortunately I'm not able to fetch and store data you have any solution please help me I'm attached my code bellow
char data_eeprom[255];
void write_eeprom(uint16_t posi,uint8_t dt)
{
HAL_I2C_Mem_Write(&hi2c1,0xA0<<1,posi,0xff,&dt,1,1000);
HAL_Delay(5);
}
uint8_t read_eeprom(uint16_t posi)
{
uint8_t dt;
HAL_I2C_Mem_Read(&hi2c1,0xA0<<1,posi,0xff,&dt,1,100);
return dt;
}
void writeString_eeprom(uint16_t posi,char*dt)
{
write_eeprom(posi,strlen(dt));
for(int a=0;a<strlen(dt);a++)
{
write_eeprom(posi+1+a,dt[a]);
}
}
void readString_eeprom(uint16_t posi)
{
uint16_t l_str=read_eeprom(posi);
memset(data_eeprom,0,255);
for(int a=0;a<l_str;a++)
{
data_eeprom[a]=read_eeprom(posi+1+a);
}
}
2021-06-05 05:21 AM
Observe SDA/SCL using oscilloscope/logic analyzer.
JW
2021-06-05 05:39 AM
0xA0 is already left aligned you shouldn't need to shift it again.
2021-06-06 11:22 AM
I remove shift right by one, its work but "data_eeprom buffer" shows value "0x19" in character
2021-06-06 11:30 AM
What's the 0xFF here?
#define I2C_MEMADD_SIZE_8BIT (0x00000001U)
#define I2C_MEMADD_SIZE_16BIT (0x00000002U)
Getting any errors/status reported?