Skip to main content
seppeltronics_v
Associate III
July 21, 2022
Solved

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

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.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
seppeltronics_v
Associate III
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?

Tesla DeLorean
Guru
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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..