2014-09-24 04:18 AM
Hi,
I have a STMCube generated project wirh I2C memory 24LC512 with following problem. The line:Status = HAL_I2C_Mem_Read(&hi2c1, IIC_ADDRESS+1, 0, I2C_MEMADD_SIZE_8BIT, pNVRawData, NVRawDataLen, 1000);is correct feeded with parameter but reads only 0xff as data.
The line:Status = HAL_I2C_Mem_Read(&hi2c1, IIC_ADDRESS+1, 0, I2C_MEMADD_SIZE_8BIT+5, pNVRawData, NVRawDataLen, 1000);is not correct because of ''+5'' (any garbage) but is working correct and reads correct value.
I'm using newest Cube & FW.Why?Whats wrong?2014-09-26 09:39 AM
Please consider using
I2C_MEMADD_SIZE_16BIT
that must return the same result thanI2C_MEMADD_SIZE_8BIT
+5. (because of the way HAL tests this parameter). Your EEPROM has 8-bit organization, which means that data is addressed 8-bit per address, and there are 32768 addresses, you need more than 8 bits to write an address, that's why you *must* useI2C_MEMADD_SIZE_16BIT
. Double check your datasheet, when you read data from EEPROM, you need to write the read pointer using two bytes, henceI2C_MEMADD_SIZE_16BIT
.2019-01-16 05:35 PM
Hi,
I'm using HAL_I2c_Mem_Read(), too.
And may I ask if STM32's I2C can generate wave like the following picture. I have tryed Mem_read() and any other function in i2c.c , but the bit following device addres is "0",which means "write" in I2c.
May you help me out, thanks.