2024-10-12 10:24 AM
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.
Solved! Go to Solution.
2024-10-12 11:30 AM - edited 2024-10-12 11:31 AM
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?
2024-10-12 11:30 AM - edited 2024-10-12 11:31 AM
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?
2024-10-12 11:45 AM
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!