0
\$\begingroup\$

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) );
<yadda..yadda..>

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): enter image description here

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?

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.