2025-10-23 7:42 AM
Hi,
I am trying to create the I2C communication using the format used from the company seller of the device.
I have to follow these steps:
I2CReadFunciton ( uint8_t slAddr,
uint8_t* wrData, int wrLen,
uint8_t* rdData, int rdLen
Initiate the bus by issuing a START condition.
If there are bytes to write (wrLen > 0):
Begin the read phase:
Terminate the transaction with a STOP condition.
Key constraints:
My problem is how to not have the stop condition in the write function using the HAL functions.
2025-10-23 7:59 AM
Please include your full chip part number in your posts.
What device are you interfacing with?
HAL_I2C_Mem_Read will issue a write then a read with a repeated-start condition. Perhaps use that or look there to see how it is done.
2025-10-23 11:47 PM
Thanks for the answer!
It's a gas sensor, but it's form the coompetition of ST, so I prefer not to say which is.
I have already used it, but it didn't work because it can happen that in the write part the wrLen cab be bigger than 1 byte, so the HAL_I2C_Mem_Read doesn't work.
In principle, it can happen I need to write 3 bytes and read 5 bytes.
I found the HAL_I2C_Master_Seq_Transmit_IT, but I am not pretty sure how to use it.
Thans in advance for the help
2025-10-27 3:49 AM - edited 2025-10-27 3:50 AM
@Fin95 wrote:It's a gas sensor, but it's form the competition of ST, so I prefer not to say which is.
That really isn't a problem: you can come to ST's forums for questions specifically about the STM32 - the way the STM32 behaves and is programmed does not depend on whether it's connected to other ST parts!
(just remember that you need to go to the sensor manufacturer for questions specifically about the sensor).
Seeing the sensor datasheet is key to understanding what you're actually trying to achieve.
2025-10-27 4:10 AM
Hi @Andrew Neil ,
Thanks for your response!
The issue isn’t with the gas sensor itself, but rather with the way I’m trying to read data via I2C, which doesn’t follow the conventional approach.
Specifically, I’m aiming for a functionality similar to HAL_I2C_Mem_Read, as suggested by @TDK . However, in my case, I need to send multiple EEPROM address bytes, followed by a restart condition without a stop bit, and then read the data buffer.
Is this kind of sequence supported by HAL_I2C_Mem_Read, or should I use a different HAL function to achieve this behavior?
Thanks again for your help!
2025-10-27 4:28 AM
@Fin95 wrote:The issue isn’t with the gas sensor itself, but rather with the way I’m trying to read data via I2C, which doesn’t follow the conventional approach.
But giving the part number allows people to check out the datasheet to see exactly what that "unconventional approach" is.
Better still, give a direct link to the datasheet.
2025-10-27 4:37 AM
Ok, the gas sensor is this: https://www.renesas.com/en/products/zmod4410?srsltid=AfmBOopelXCvozcRLAmjhgqs_Rt6-DrQ8_zLMNfFxPtMkawyeqX11P6P
In the Datasheet you are can check the I2C protocol and in the User Manual you can check the example program I am importing (I have to implement the i2c write and read).
I have already tried to use the HAL_I2C_Mem_Read in the read function, but it doesn't work.
Thanks again for the support!
2025-10-27 4:42 AM
So have you tried putting "ZMOD4410 stm32" into your favourite internet search engine?
eg, Someone here on the Renesas forum says that HAL_I2C_Mem_Write/Read worked for them ...
2025-10-27 4:50 AM
Yes, I have tried, but it doesn't work.
I will retry with these functions.
Thanks