2025-12-18 7:57 AM
Hello,
I’m using an STM32WBA65 and trying to communicate with a peripheral (PTX30W) over I2C1.
The peripheral requires the following I²C sequence:
However, using HAL_I2C_Master_Transmit() followed by HAL_I2C_Master_Receive() does not work, because both HAL functions generate a STOP condition, and the PTX30W does not accept a STOP between the write and read phases.
On STM32WBA, I don’t see a HAL equivalent of HAL_I2C_Master_TransmitReceive() that would allow a repeated START without a STOP in between.
My questions are:
Is there a way to achieve a WRITE + REPEATED START + READ sequence using the HAL on STM32WBA?
Or is the correct approach to switch to the LL (Low Layer) I2C driver to get finer control over START/STOP conditions?
Any guidance or best practices for this use case would be appreciated.
Thanks in advance.
here is the i2c protocol :
2025-12-18 8:23 AM
Use HAL_I2C_Mem_Read to write 1-2 bytes, then read a bunch, using a repeated start.
2025-12-18 8:57 AM
@TDK wrote:Use HAL_I2C_Mem_Read to write 1-2 bytes, then read a bunch, using a repeated start.
@Emil Damkjaer PETERSEN @Loic CHOSSAT this is particularly poorly described in the HAL documentation:
I really don't think it's at all clear from this description that "MEM" is the one to use in this application?
Please can we have a clear description like @TDK's in the HAL manuals - this kind of question comes up frequently on the forum!
I suspect that most applications where HAL_I2C_Mem_Read is the correct choice are not actually "memory" devices - as is the case here.
2025-12-18 9:34 AM
I think the HAL_I2C_Mem_Read naming is appropriate. Most uses of this are for actual memory addresses or register analogs. For example, accelerometers and other sensors, EEPROMs, LCD character displays. Just my opinion.