AnsweredAssumed Answered

Unable to Read and Write to I2C EEPROM

Question asked by mattoo.anuj on Feb 23, 2017
Latest reply on Jan 22, 2018 by Shashank TS

I am using atmega AT24C256 EEPROM and STM32F0 discovery module. I am struggling to read/Write to the memory. Here is the example I trying to use:-


#define I2C1_DEVICE_ADDRESS   0x50           /* A0 = A1 = A2 = 0 */
#define MEMORY_ADDRESS 0x07


Buffer[0] = 'M';
HAL_I2C_Mem_Write(&hi2c1, (uint16_t) I2C1_DEVICE_ADDRESS<<1, MEMORY_ADDRESS, 1, Buffer, 1, 5);
Buffer[0] = 0x00;
HAL_I2C_Mem_Read(&hi2c1, (uint16_t) I2C1_DEVICE_ADDRESS<<1, MEMORY_ADDRESS, 1, Buffer, 1, 5); 
if (Buffer[0] == 0x4D) // if xBuffer[0] = 'M'
Test = 1;



On reading from memory, I do not get the  'M' or but some '255' instead. Where is the problem? Do I need to configure clock properly? I used CUBEMX for basic routines.