I am working with an STM32F0 running at 3.3 V. I'm trying to drive a motor controller with PWM from the microcontroller. The motor controller requires an analog input of between 0 - 5 V to control the duty cycle of the motor.
I have the output pin of the microcontroller (5 V tolerant) configured as open drain, high speed, and I am using a 220 ohm pullup resistor to 5V. PWM frequency is approximately 12 kHz.
When I measure the output at the microcontroller pin, I get 0.5 V when the pin has 0% duty cycle, and +- 2.9 V when the pin has 100% duty cycle.
If I use a 2k2 resistor, the problem gets worse and I get about 1.8 V at the output pin on 100% duty cycle. I also tried connecting the pin directly to 5 V, however when I do this, it does not get pulled low on 0% duty cycle, but sits at 5 V.
As far as I understand, this configuration should work correctly. Can anyone provide any suggestions as to why this is not working for me?