cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 24LC128 EEPROM

er3481
Senior

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);

7 REPLIES 7
S.Ma
Principal

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

Hi,

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

Thanks

Pavel A.
Evangelist III

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
Senior

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.

> 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

: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.

Then, use a logic analyzer