Skip to main content
Osto
Senior
September 24, 2014
Question

HAL_I2C_Mem_Read reads only correct if the parameter is wrong

  • September 24, 2014
  • 11 replies
  • 4269 views
Posted on September 24, 2014 at 13:18

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?
    This topic has been closed for replies.

    11 replies

    dbo
    Associate II
    January 17, 2019

    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.

    0690X000006D8D0QAK.jpg