Skip to main content
gocchan
Associate III
July 30, 2026
Solved

How to implement I2C communication between two STM32s.

  • July 30, 2026
  • 4 replies
  • 85 views

I'm implementing I2C communication using an STM32WBA2 as the Master and an STM32U0 as the Slave.
I've implemented a process to send one byte of data (0x75) from the Master to the Slave, with the Slave Address set to 0x68. However, when I check the SCL/SDA waveforms, it appears there's no ACK from the Slave.


On the other hand, the Slave receives an event in HAL_I2C_AddrCallback() when it receives 0x68, but the value read by HAL_I2C_Slave_Receive() is empty.
 


How can I receive 0x75 from the Master?
I've attached the main.c files for both the Master and Slave.
The CubeMX configuration is as follows:
 

 

Best answer by Andrew Neil

Try to find some example Slave code with a more complete ..._AddrCallback().

+1

 

@gocchan The Cube firmware packs for both STM32WBA and STM32U0 have examples of doing I2C between two boards:

https://github.com/STMicroelectronics/STM32CubeU0/tree/main/Projects/NUCLEO-U031R8/Examples/I2C/I2C_TwoBoards_ComIT

https://github.com/STMicroelectronics/STM32CubeWBA/tree/main/Projects/NUCLEO-WBA25CE1/Examples/I2C/I2C_TwoBoards_ComIT

 

You should be able to access these direct from CubeMX.

4 replies

David Littell
Senior II
July 30, 2026

The flat line on the clock indicates the Slave is holding it low until the code indicates it should ACK the address.  Try to find some example Slave code with a more complete ..._AddrCallback().

Andrew Neil
Andrew NeilBest answer
Super User
July 30, 2026

Try to find some example Slave code with a more complete ..._AddrCallback().

+1

 

@gocchan The Cube firmware packs for both STM32WBA and STM32U0 have examples of doing I2C between two boards:

https://github.com/STMicroelectronics/STM32CubeU0/tree/main/Projects/NUCLEO-U031R8/Examples/I2C/I2C_TwoBoards_ComIT

https://github.com/STMicroelectronics/STM32CubeWBA/tree/main/Projects/NUCLEO-WBA25CE1/Examples/I2C/I2C_TwoBoards_ComIT

 

You should be able to access these direct from CubeMX.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
LCE
Principal II
August 3, 2026

So slave clock stretching is enabled.

Check what the RM says about when this is done.

In the L07x I’m currently working with I have the ADDR interrupt activated, so the clock stretching ends and the correct address is ACK’d when clearing the ADDR interrupt flag, Check if this happens somewhere in your code.

			/* clear ADDRESS match flag
* -> this ends CLOCK STRETCHING
*/
I2C1->ICR |= I2C_ICR_ADDRCF;

 

gocchan
gocchanAuthor
Associate III
August 6, 2026

As you commented, developing based on I2C_TwoBoards_ComIT achieved the objective.

Thank you.