I had same issue using nucleo f303 board. I2C got stuck (error flag) with SPI init. I'm not sure what is issue, but I found workaround to use I2C and SPI by DeInit SPI before using I2C. (SPI Init should done to use SPI again..).Do HAL_SPI_MspDeInit(&...