I am using 24AA16 EEPROM to store my data. I have write the code for read and write using STM32Cube IDE. I am using Nucleo-F410RB Dev board. Below code is for write,
uint8_t data_write[EEPROM_PAGESIZE] = "Hello"; // Data to be written
// Example write operation
printf("Writing data to EEPROM...\r\n");
s = HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, 0x0000, I2C_MEMADD_SIZE_16BIT, data_write, EEPROM_PAGESIZE, HAL_MAX_DELAY);
HAL_Delay(50);
if (s == HAL_OK) {
printf("Data write successful.\r\n");
} else {
printf("Data write failed.\r\n");
Error_Handler();
}
The page size and address for this EEPROM is,
EEPROM_PAGESIZE = 16 //in bytes
EEPROM_ADDRESS = 0xA0
And below is the code for Read,
uint8_t data_read[EEPROM_PAGESIZE]; // Data to be read
// Example read operation
printf("Reading data from EEPROM...\r\n");
r = HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, 0x0000, I2C_MEMADD_SIZE_16BIT, data_read,
EEPROM_PAGESIZE, HAL_MAX_DELAY);
//HAL_Delay(50);
if (r == HAL_OK) {
printf("Data read successful: %s\r\n", data_read);
} else {
printf("Data read failed.\r\n");
Error_Handler();
}
But read write operations can't done! Can anyone guide me to solve this issue? I am new to STM32Cube IDE!