2021-09-23 04:55 AM
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.
2021-09-24 11:55 AM
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.
2021-09-26 06:22 PM
Thank you for your advice.
I will proceed with the test as advised.