2026-05-11 1:13 AM
Here are the logs and waveforms. The slave device of IIC is unable to raise the SCL response. The data cannot be sent out either. The code is provided in the attachment.
HAL_I2C_AddrCallback: 开始接收数据
接收到字节[0]: 0x40
接收到字节[1]: 0x03
接收到字节[2]: 0x22
接收到字节[3]: 0xFE
接收到字节[4]: 0xBE
HAL_I2C_ListenCpltCallback: 开始接收数据
接收到字节[0]: 0x41
HAL_I2C_ListenCpltCallback: 开始发送数据
发送字节[0]: 0x05
发送字节[1]: 0x62
发送字节[2]: 0xFE
发送字节[3]: 0xBE
发送字节[4]: 0x30
发送字节[5]: 0x31
Solved! Go to Solution.
2026-05-21 1:47 AM
I'm aware of all of this. The cause of the problem lies in the usage issue of the HAL_I2C_Slave_Seq_Receive_IT interface.
The received byte count must be the same as the number sent by the host.
Adding or subtracting just one byte will cause the system to enter the ER interrupt.
2026-05-11 1:39 AM
Hello @AngusHZ and welcome to the ST community,
As technical admin in this community, let me ask you to provide more details about your project:
- What STM32 part number are you using?
- What I2C slave are you connecting to the STM32?
- Your schematic
Please read How to write your question to maximize your chances to find a solution
2026-05-11 7:52 PM
STM32H743VIT6 is slave,I'm use STM32H743VIT6
2026-05-12 1:22 AM
You still didn't provide all the needed information:
For the second question what is the master?
2026-05-12 6:24 PM
The master is another device.
STM32 is slave.
In the first question, the attachment contains the code.
2026-05-12 11:07 PM - edited 2026-05-13 1:46 AM
Pull-up resistors are essential for the functionality of the I2C bus.
And more specifically, pull-ups in the range of 1k...5kOhm.
This is why @mƎALLEm asked for a schematic.
Second, I2C means "Inter-Ic-Bus", and was designed by Phillips for relatively short connections between components on a single PCB. The long flying wires in the picture will most probably create problems on the physical / signal layer.
Those would be visible on an oscilloscope, but not a logic analyser.
2026-05-21 1:47 AM
I'm aware of all of this. The cause of the problem lies in the usage issue of the HAL_I2C_Slave_Seq_Receive_IT interface.
The received byte count must be the same as the number sent by the host.
Adding or subtracting just one byte will cause the system to enter the ER interrupt.
2026-05-21 2:03 AM
> The cause of the problem lies in the usage issue of the HAL_I2C_Slave_Seq_Receive_IT interface.
> The received byte count must be the same as the number sent by the host.
I don't use Cube/HAL generated code.
Check your actual I2C bus traffic, and compare it against your expectations.
Either your protocol does not match, or the byte counting is not correct.
2026-05-21 2:13 AM
slave I2C+DMA
Are there any examples?
HAL_I2C_Slave_Seq_Receive_IT The limitations are too severe.
Replacing it with HAL_I2C_Slave_Seq_Receive_DMA will trigger the ER interrupt. ER code is 0x00000004
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
{
if (hi2c->Instance == I2C1)
{
if (TransferDirection == I2C_DIRECTION_TRANSMIT)
{
Rx_len = 0;
memset(I2C_rxBuffer,0,4);
HAL_I2C_Slave_Seq_Receive_IT(&hi2c1, I2C_rxBuffer, 1, I2C_FIRST_AND_LAST_FRAME);
}
else
{
HAL_I2C_Slave_Seq_Transmit_IT(&hi2c1, I2C_txBuffer, Tx_len, I2C_FIRST_AND_LAST_FRAME);
}
}
}
2026-05-21 2:29 AM
That's a new question - you have a separate thread on that:
STM32H743VGT6 how to use slave I2C+DMA
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.