cancel
Showing results for 
Search instead for 
Did you mean: 

Reading I2c with sub-address

baranovus
Associate III

Hello All.

Reading a register value from an I2C device assumes:  Writing the device address-> Writing the register address without STOP-> Reading the value . I am trying to figure out if I can do it using only available HAL functions but I don't see how. Simple Write followed by Read includes STOP, which is not in full compliant with the rules. 

Yes, if needed, I can rewrite everything but maybe there is an option, which I don't notice?

I use STM32G0B0 with HAL libraries.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks! That is the solution.

View solution in original post

2 REPLIES 2

For EEPROM, IMU, etc this form tends to be workable

HAL_StatusTypeDef status = HAL_I2C_Mem_Read(&I2CHandle, (0x42 << 1), 0xFF, 1, buffer, len, 300); // Read data block from register position 0xFF (8-bit)

Supports 8 and 16-bit addressing within the Slave, and whatever length auto-increments

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

Thanks! That is the solution.