cancel
Showing results for 
Search instead for 
Did you mean: 

24C16RP EEPROM INTERFACING WITH STM32G070CBT6

RChou.1
Associate III

Hello all,

I am trying to interface 24C16RP EEPROM with my MCU soldered on breakout board and  it seems like the EEPROM is behaving very weird when i am trying to write and read. first of all it starts to write from position 1 not from zero of an array that i have created to store the data and i tried a lot to figure out the cause but i couldn't and the weird part is that after writing to a specific page if am trying to read any other page of the entire page address it returns the same date i have written to it. As i know this EEPROM has 16 byte of page size and 128 pages correct me if i am wrong. With that said i am attaching the cube mx code and the ioc file and some screen short for your better understanding. Please help me if you find something error in my code.

Thanks

 

 

uint8_t data_Read[16];
uint8_t data_Write[16]="1234567898765432";

int main(void)
{
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_I2C1_Init();
  MX_USART1_UART_Init();

  HAL_I2C_Mem_Write(&hi2c1, 0XA0, 1, 2, data_Write, 16, 1000);
  HAL_Delay(5);
  HAL_I2C_Mem_Read(&hi2c1, 0XA0, 9, 2, data_Read, 16, 1000);
  while (1)
  {
  HAL_UART_Transmit(&huart1, data_Read, 16, 1000);
  HAL_Delay(1000);
  }
}

 

 

 

11 REPLIES 11

If You set MemAddress to 6 You will read starting from Byte 6 (so probably what You read is "James...!!") if You want to access the 6.  16Byte page you have to set MemAddress to 16*6 = 96.

 

uint8_t data_Read[16];
uint8_t data_Write[16]="hello james...!!";

 

 

So, i can only write with the gap of 16, 

means page 1 = 16byte = index 0 to 15

page 2 = 16byte = index 16 to 31

page 3 = 16byte = index 32 to 47 and so on...

And for reading page 1's entire content i have to put 

 

HAL_I2C_Mem_Read(&hi2c1, 0xA0, 1, 1, data_Read, 16, 100);

 

it will return me the entire 16byte of the content and  if i use any number below 16byte it will return me the data from where i have requested like

 

HAL_I2C_Mem_Read(&hi2c1, 0xA0, 3, 1, data_Read, 16, 100);

 

 it will return page 1's llo james...!! from page 1 and and 3bytes of data from page 2