Question
Unable to Read and Write to I2C EEPROM
Posted on February 23, 2017 at 21:43
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:-
&sharpdefine I2C1_DEVICE_ADDRESS 0x50 /* A0 = A1 = A2 = 0 */
&sharpdefine MEMORY_ADDRESS 0x07Buffer[0] = 'M';
HAL_I2C_Mem_Write(&hi2c1, (uint16_t) I2C1_DEVICE_ADDRESS<<1, MEMORY_ADDRESS, 1, Buffer, 1, 5); HAL_Delay(1000); Buffer[0] = 0x00; HAL_Delay(1000); 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.
#cubemx #eeprom #hal #stm32f0 #i2c