2024-08-07 12:12 AM - edited 2024-08-07 12:14 AM
HI
Got an I2C device connected to my p nucleo wb 55 board. currently no luck communicating.
I've been instructed to to use a repeated start condition in I2C https://www.i2c-bus.org/repeated-start-condition/
Not sure if my current HAL functions work for an I2C repeated start condition device? they are :
HAL_I2C_Mem_Write XXX
HAL_I2C_Master_Transmit XXX
Any other example I can use ?
need to achieve this :
S start
R restart
THNAKS
Solved! Go to Solution.
2024-08-07 01:36 AM
Hello @DS.4
To achieve a repeated start condition with your I2C device, you will need to use specific HAL functions that support repeated start conditions. The functions you mentioned (HAL_I2C_Mem_Write and HAL_I2C_Master_Transmit) do not support repeated start conditions.
For repeated start conditions, you should use the following HAL functions:
These functions are designed to handle sequential transmit and receive operations, which include the capability to perform repeated start conditions.
Please refer to these examples for farther more details:
2024-08-07 01:36 AM
Hello @DS.4
To achieve a repeated start condition with your I2C device, you will need to use specific HAL functions that support repeated start conditions. The functions you mentioned (HAL_I2C_Mem_Write and HAL_I2C_Master_Transmit) do not support repeated start conditions.
For repeated start conditions, you should use the following HAL functions:
These functions are designed to handle sequential transmit and receive operations, which include the capability to perform repeated start conditions.
Please refer to these examples for farther more details:
2024-08-07 04:22 AM - edited 2024-08-07 04:23 AM
@Saket_Om thanks! just 2 follow up questions:
Can I set/configure the sequential transmit
to behave as the regular ones I use :
Is it possible?
Also what is the difference between the projects:
?
Thanks!
2024-08-07 05:55 AM - edited 2024-08-07 06:04 AM
Hello @DS.4
>> Can I set/configure the sequential transmit
to behave as the regular ones I use :
Is it possible?
I didn't understand your question. If you want to say configure HAL_I2C_Master_Sequential_Transmit_IT to behave like HAL_I2C_Master_Transmit_IT, my answer is yes. You need to set the XferOptions argument to I2C_FIRST_AND_LAST_FRAME. This setting ensures that the transfer is treated as a single transaction, similar to how HAL_I2C_Master_Transmit_IT operates.
Please refer to this post for more details.
The difference between the two examples is that the first one uses the sequential API to send and receive simple data between two boards, while the second one uses the sequential API to send and receive commands between two boards. Please see the readme files for more details.
2024-08-07 11:35 AM
@Saket_Om Thanks for the quick answer, you are the best!