cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G491 restarts when using I²C

MHens.2
Associate II

Hi, 

I am having a problem with a unexpected restart.

The first time I use the I²C bus by invoking HAL_I2C_Master_Transmit, the MCU restarts after reaching this line:

line 7276 of stm32g4xx_hal_i2c.c

/* update CR2 register */
MODIFY_REG(hi2c->Instance->CR2, \
((I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | \
(I2C_CR2_RD_WRN & (uint32_t)(Request >> (31U - I2C_CR2_RD_WRN_Pos))) | \
I2C_CR2_START | I2C_CR2_STOP)), tmp);

 

It just goes straight to the reset handler, no hard fault is triggered. I am using I2C1, and that shares the BOOT0 pin with I²C1-SCL, but that should be irrelevant, as we are already running in the user code. I'm really at loss what is going on here. I appreciate any suggestions.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

So can your I2C2 actually use some pin that is shared with NRST? Look at the pin mapping in your code or CubeMX. Are the I2C2 wires touching ground?

 

 

View solution in original post

2 REPLIES 2
Pavel A.
Evangelist III

So can your I2C2 actually use some pin that is shared with NRST? Look at the pin mapping in your code or CubeMX. Are the I2C2 wires touching ground?

 

 

It doesn't, but your comment had me looking at NRST with my scope. It triggered.

I found a solder ball under the microscope that shorted NRST to the I²C bus.

Thanks!