Howdy,
by design slave IC pusles SCL (when I2C is not used) every time data is ready. While testing with Arduino environment and UNO board those pulses did not give any trouble. But when used with STM32 (HAL) I2C due to those pulses gets stuck. Salt to the wound is that my first I2C command is to dissable those INT signals (have no idea why they set it on by dafault).
Tested with logic analyser and debug tools (register states).
Now lets get technical...
Reference manual states:
I2C interface can operate in one of the four following modes:
• Slave transmitter
• Slave receiver
• Master transmitter
• Master receiver
By default, it operates in slave mode. The interface automatically switches from slave to
master, after it generates a START condition and from master to slave, if an arbitration loss
or a Stop generation occurs, allowing multimaster capability.From what I found there is no way to force I2C to be in master mode all the time.
So in slave mode MCU assumes data is being sent and trigers busy flag:
I2C Status register 2 (I2C_SR2)
Bit 1 BUSY: Bus busy
0: No communication on the bus
1: Communication ongoing on the bus
– Set by hardware on detection of SDA or SCL low
– cleared by hardware on detection of a Stop condition.
It indicates a communication in progress on the bus. This information is still updated when
the interface is disabled (PE=0).Alrighty then, lets triger START condition on I2C init so MCU would stay in Master mode, as that register R/W that might help, right?
Master mode is selected as soon as the Start condition is generated on the bus with a START bit.
Set the START bit in the I2C_CR1 register to generate a Start conditionI've tried writing START bit on I2C peri setup, did not help – bit still stays 0.
At this point my only valid idea is to disable INTs by bitbanging and then init I2C peri, but that is not a solution I would be happy in a long run...
Any ideas?
EDIT:Made a picture with bitbanging in effect:
