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 = 'M';
HAL_I2C_Mem_Write(&hi2c1, (uint16_t) I2C1_DEVICE_ADDRESS<<1, MEMORY_ADDRESS, 1, Buffer, 1, 5);
Buffer = 0x00;
HAL_I2C_Mem_Read(&hi2c1, (uint16_t) I2C1_DEVICE_ADDRESS<<1, MEMORY_ADDRESS, 1, Buffer, 1, 5);
if (Buffer == 0x4D) // if xBuffer = '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.