BluePill analogWrite(PB8 ) PWM and I2C (PB10,PB11) collision

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
PeKu9999
Posts: 1
Joined: Tue Aug 03, 2021 8:12 pm

BluePill analogWrite(PB8 ) PWM and I2C (PB10,PB11) collision

Post by PeKu9999 »

I use BluePill in a project and need to work with I2C Wire and analogWrite () PWM commands in the same code.

Now the following isssue has catched me.

I put I2C Wire on the pins PB10, PB11 and i use the analogWrite PB8 for a PWM motor control Pin due to the lack of other free pins.
When I start the code and send data back between sensors and MCU via I2C, it works perfectly.

However, as soon as I send a one or more analogWrite (PB8, XXX) commands, the I2C interface stops working completely.
I attached an oscilloscope to the SCL, SDA pins and it really is the case that no more data or clock pulses are sent as soon as analogWrite(PB8) commands ones executed. No further Wire Commands start a Hardware SCL, SDA pulses. The pins a dead.

For me it looks like analogWrite (PB8, XXX) would bend a timer internally in the MCU, which is also required for I2C, and then it no longer receives a clock and can no longer be used via the interface.

It is also interesting that the I2C interface works normally when I use analogWrite (PB10, PB11, PA6) for motor controls. Only on the analogWrite(PB8 is I2C completely paralyzed.

I need this pin due to the lack of other pins that I have already used.
Perhaps someone knows this phenomenon himself and has a solution to decouple PWM and I2C from this pin PB8 so that both can work independed.

Thanks for hints
Mike
Post Reply

Return to “General discussion”