# I2C on STM32L100 - “faulted start”

I'm using stm32l100C6-A to communicate with gas gauge via I2C. My code tries to start I2C transfer, like this:

I2C1->CR1 |= I2C_CR1_START;
// waiting for EV5 - Master Mode Select
while( ! (I2C1->SR1 & I2C_FLAG_SB) );


and sometimes it works, transfer is completed, all is well. But some other times instead of full transfer on I2C lines I see this (SCL and SDA are in different scale):

As far as I can see - that's just a normal start condition. But I2C1->SR1 is zero, no bits are set, no matter how long I wait.

After that - making I2C reset via I2C1->CR1 |= I2C_CR1_SWRST; doesn't help, making full reinitialization of I2C doesn't help, resetting RCC for I2C doesn't help. Only full MCU reset helps.

Since full reset helps, the problem must be in the MCU but I couldn't find anything similar in the errata or internet.

I'm using I2C on 85kHz.

I have no idea what's going on and I don't like resetting MCU as a workaround. Any ideas?

• Is your peripheral clock at least 2MHz? – Annie Jul 12 '18 at 20:45
• Yes, it's 32 MHz, straight from PLL. – Amomum Jul 12 '18 at 21:47