STM32F103C8 I2C HAL lockup

Post Reply
mike442
Posts: 2
Joined: Wed Feb 24, 2021 12:30 pm

STM32F103C8 I2C HAL lockup

Post by mike442 »

I know this has been discussed before and the "bug" is still there hiding. If you pull the ground lead from the bus off there will be a complete lockup.
It's most probably conserning STM's HAL not stm32duino, but still this would be great to get fixed in some way.

I have narrowed it out to the file:
Arduino15\packages\STM32\hardware\stm32\1.9.0\system\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c
-In function HAL_I2C_IsDeviceReady I can't get past the row, until I correct the sensor...
/* Generate Start */
SET_BIT(hi2c->Instance->CR1, I2C_CR1_START);

It will always freeze here...
The only way to get it up and runing is the wathcdog reboot, but still again on startup we hit it again. So this renders the unit totally useless because of a for ex. broken sensor or cable.

br. Mike
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8 I2C HAL lockup

Post by mrburnette »

Good design and testing procedures require that all sensors, grounds, and power grounds be connected before power-on.

Cables with unconnected grounds, open shielding act as tiny antennas and on peripheral ports such as I2C can cause an impedance mismatch which may cause AC hum introduced to the bus with a magnitude above the "1" logic level. Such sporadic signals can cause saturation within the microcontroller on the ESD diodes.

So, just have the power off, connect everything, ensure that I2C has the correct resistors, and then apply positive voltage.
mike442
Posts: 2
Joined: Wed Feb 24, 2021 12:30 pm

Re: STM32F103C8 I2C HAL lockup

Post by mike442 »

Yes you 100% correct, but still a small failure in the hw can't kill the whole thing in one shot. I already tested out a few other repos for ex. stm32cubeide with same type of code including ethernet and i2c etc., but no stm32duino/Arduino and it works flawlessly and allways returns back itself after failure.
Post Reply

Return to “PR's bugs and enhancements”