Showing results for 
Search instead for 
Did you mean: 

STM32F103VE <-> STM32F302CB I2C communication problem


Hello, teachers. I'm an introductory to stm32.

I am posting like this because there is a situation where communication is not possible while communicating i2c between stm32.

This is the current structure.

STM32F103VE Use 1 Master, STM32F302CB Use 5 Slaves, Flow Sensor (SLF3S-600F) Use 1 Slave

Slave has different addresses.

16(Flow Sensor), 18, 20, 22, 24, 26

1(Master) : 6(Slave) Structure

This is the problem that arises.

If you do HAL_I2C_Master_Receive_IT at 103, you will get a return value to HAL_ERROR.

If you erase HAL_I2C_Master_Receive_IT from 103 and only perform HAL_I2C_Master_Transmit_IT, I2C communication works normally.

When HAL_I2C_Master_Transmit_IT is transmitted by 3 bytes in 103, I2C communication is interrupted. You have to send only 1 byte to communicate.

It doesn't change to HAL_I2C_STATE_READY, it's tied to HAL_I2C_STATE_BUSY_RX, and it doesn't change.

Among 103 debugging, the process of entering HardFault_Handler is shown.

What's wrong with me? It's so hard. Help me, teachers.


You've listed a bunch of problems. There are I2C examples in the CubeMX repository. I would recommend getting one of those up and running. Use blocking functions and graduate to IT or DMA functions once those are working.

If you have a hard fault, there is something else going wrong with your program (very likely) unrelated to HAL drivers. Look at SCB registers and/or call stack to debug.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for your advice.

I will proceed with the test as advised.