I2C conflict with PWM on STM32F103

15 Feb 2016

Hi I noticed a conflict on my STM32F103 board when I was using PB_5 as a PWM concurrently with I2C1. If I don't instantiate I2C1, the PWM output on PB_5 works great. As soon as I instantiate I2C1, the PWM on this output dies.

I do see that PB_5 has an alternate function of "I2C_SMBAI" which makes me suspicious that this is the source of the problem. I do notice a footnote on the datasheet from ST that states:

"If several peripherals share the same I/O pin, to avoid conflict between these alternate functions only one peripheral should be enabled at a time through the peripheral clock enable bit (in the corresponding RCC peripheral clock enable register)."

I was hoping that there was a way to ignore SMBAI and use PB_5 as a PWM output channel.

Has anyone else encountered this issue? Any thoughts this problem being a conflict with the alternate function? I do notice I can declare PB_5 as a GPIO (DigitalOut) and it works correctly with PWM.

Thanks Bill

<EDIT> I have tracked it down to the conflict on the resource. I forced the I2C clock off during the test via the RCC_APB1ENR register and the PWM came back to life on the pin

25 Mar 2016

Hi Bill,

I just encountered the same problem, I can't change PWM duty cycle after turning on I2C. How did you forced the I2C clock off?

28 Mar 2016

Take a look at Peripheral_PowerDown() function. See a list of flags it takes here https://developer.mbed.org/cookbook/Power-Management#code-example-reducing-mbed-power.

29 Mar 2016

Fan Fei wrote:

Hi Bill,

I just encountered the same problem, I can't change PWM duty cycle after turning on I2C. How did you forced the I2C clock off?

I wrote to the memory location that controls the I2C peripheral. Later I found there was an "errata" that stated this is the correct operation of the device. Thank you ST.