Skip to main content
er3481
Associate III
Jul 2, 2020 1:42 PM UTC
Question

STM32F103 24LC128 EEPROM

Hi,

I am trying to write and read 64bytes data to 24LC128 eeprom with code below. For first64 bytes i can write and read clearly but the next values can not be written. What is wrong with me ? Any advises ?

HAL_I2C_Mem_Write(&hi2c1,(uint16_t)0xA0,0x00,I2C_MEMADD_SIZE_16BIT,save1,0x0040,1000);
			HAL_Delay(25);
			HAL_I2C_Mem_Write(&hi2c1,(uint16_t)0xA0,0x0040,I2C_MEMADD_SIZE_16BIT,save2,0x0040,1000);
			HAL_Delay(25);
			HAL_I2C_Mem_Write(&hi2c1,(uint16_t)0xA0,0x0080,I2C_MEMADD_SIZE_16BIT,save3,0x0040,1000);
			HAL_Delay(25);
			HAL_I2C_Mem_Write(&hi2c1,(uint16_t)0xA0,0x00C0,I2C_MEMADD_SIZE_16BIT,save4,0x0040,1000);
 
 
 
 HAL_I2C_Mem_Read(&hi2c1,(uint16_t)0xA0,0,I2C_MEMADD_SIZE_16BIT, save1,0x0040,1000);
	HAL_Delay(25);
	HAL_I2C_Mem_Read(&hi2c1,(uint16_t)0xA0,0x0040,I2C_MEMADD_SIZE_16BIT, save2,0x0040,1000);
	HAL_Delay(25);
	HAL_I2C_Mem_Read(&hi2c1,(uint16_t)0xA0,0x0080,I2C_MEMADD_SIZE_16BIT, save3,0x0040,1000);
	HAL_Delay(25);
	HAL_I2C_Mem_Read(&hi2c1,(uint16_t)0xA0,0x00C0,I2C_MEMADD_SIZE_16BIT, save4,0x0040,1000);

This topic has been closed for replies.

7 replies

S.Ma
Principal
Jul 2, 2020 2:39 PM UTC

check the page size of the EEPROM. It's like a flash sector.

er3481
er3481Author
Associate III
Jul 2, 2020 4:04 PM UTC

Hi,

The page size is 64Bytes according to eeprom datasheet, so i have used "0x0040" for page size. Is it wrong ?

Thanks

Pavel A.
Jul 2, 2020 4:35 PM UTC

Should the 16-bit address be big endian? Check the code which byte is sent first. On the wire it should be big endian (high byte goes 1st)

-- pa

er3481
er3481Author
Associate III
Jul 2, 2020 6:24 PM UTC

Ok, i don't have problem for first 64bytes writing and reading, i have problem with second 64bytes and so on. So, if there is problem with 16-bit adress big or low endian, then i would have problem with first 64bytes writing and reading, right?. Any advise ?

Thanks.

Pavel A.
Jul 2, 2020 7:52 PM UTC

> So, if there is problem with 16-bit adress big or low endian, then i would have problem with first 64bytes writing and reading, right?

Haven't you noticed that address 0 is same in either big and little endian format? :)

-- pa

er3481
er3481Author
Associate III
Jul 3, 2020 6:32 AM UTC

:face_with_tears_of_joy: I supposed that you mean device address. Yes you are right, but when i changed the memory address big endian and low endian the result is same.