Showing results for 
Search instead for 
Did you mean: 

F446 and I2C-SMBUS HAL problem


Using Cube IDE. Generated a fresh project for a stm32f446ve target.

Activated with CubeMX uinder I2C a port with "SMBUS-two-wire-interface".

Then, without doing nothing more i have builded the configuration and flashed to target.

as soon as i start the mcu, it goes to hardfault.

Further investigation led to a DIVISION_BY_ZERO during SMSUS peripheral initialization (HAL_SMBUS_Init(&hsmbus1)  ).

The division by zero arise when doing :

MODIFY_REG(hsmbus->Instance->CCR, (I2C_CCR_FS | I2C_CCR_DUTY | I2C_CCR_CCR), SMBUS_SPEED_STANDARD(pclk1, hsmbus->Init.ClockSpeed));

hsmbus->Init.ClockSpeed is not set, nor in the cube-mx i have the entry to input it.

Is that a bug or i am not using correctly that ?

i was succesfull in interfacing a fuel gauge with an F3 (STM32F302) mcu and HAL.

thanks !

ST Employee

Hi @MBran.3​ ,

You are right; ClockSpeed initialization is missing.

This parameter needs to be > 0 and <= 100000.

If you enable the Assert check, you will get an assert error when checking the value of this parameter in HAL_SMBUS_Init before trying to modify registers.

This is highlighted to STM32CubeMX team who will take care to provide a fix. Thanks for reporting this issue.


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.