Skip to main content
Dhiraj Ghodmare
Associate
June 5, 2021
Question

how can I fetch external eeprom 24c64 using stm32f0 cortex MO based controller ?

  • June 5, 2021
  • 2 replies
  • 1417 views

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);

}

}

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
June 5, 2021

Observe SDA/SCL using oscilloscope/logic analyzer.

JW

Tesla DeLorean
Guru
June 5, 2021

0xA0 is already left aligned you shouldn't need to shift it again.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Dhiraj Ghodmare
Associate
June 6, 2021

I remove shift right by one, its work but "data_eeprom buffer" shows value "0x19" in character

Tesla DeLorean
Guru
June 6, 2021

What's the 0xFF here?

#define I2C_MEMADD_SIZE_8BIT   (0x00000001U)

#define I2C_MEMADD_SIZE_16BIT   (0x00000002U)

Getting any errors/status reported?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..