Skip to main content
Visitor II
July 21, 2022
Solved

HAL_I2C_Mem_Read() put's out a write on the STM32G4?

  • July 21, 2022
  • 2 replies
  • 965 views

Hello,

if I call the read function it sends a write on the I2C. What am I doing wrong?

Thanks a lot, Best Regards, Seppel

uint8_t i2cData[8U];
uint8_t i2cDevAdr = (0x53 << 1U);
 
HAL_I2C_Mem_Read (&hi2c2, i2cDevAdr , 0x00, 1U, i2cData, 1U, HAL_MAX_DELAY);
 

0693W00000QLoFRQA1.png

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    Of course it does, it's a memory/register access command.

    It does a I2C W of 8 to 16-bit to the device, and then reverses, and reads the data from the device at that address

    The 0x53 is the SLAVE Address of the I2C

    The 0x00 is the ADDRESS within the devices address space, ie an EEPROM, FLASH, RTC, etc

    2 replies

    Graduate II
    July 21, 2022

    Of course it does, it's a memory/register access command.

    It does a I2C W of 8 to 16-bit to the device, and then reverses, and reads the data from the device at that address

    The 0x53 is the SLAVE Address of the I2C

    The 0x00 is the ADDRESS within the devices address space, ie an EEPROM, FLASH, RTC, etc

    Visitor II
    July 21, 2022

    Thanks, very true, I was confused,... nearly midnight and I can't get the device to respond,... just gives me a NACK, Signals are good, debugging since hours :\ ,... can I delete that useless Post somehow?

    Graduate II
    July 22, 2022

    Let's not delete things.. damages the forum.

    The mechanics of I2C can be confusing at the best of times, and so many devices have odd quirks and behaviours.