Interfacing with an h-bridge ic (L298n) using a single pwm pin

Hello

I would like to know if its advisable to control an h-bridge ic (L298N) using a single PWM pin. Let me explain: by driving ENB pin High and by feeding complementary PWM (achieved by using a simple Npn transistor inverter circuit to invert Pwm signal from Arduino) to IN1 and IN2, the dc motor connected to OUT1 and OUT2 is working (as shown in schematic below):

In this setup I am only using a single PWM: a duty cycle of 0% is maximum speed in one direction and a duty cycle on 100% is maximum speed in the other direction and a duty cycle of 50% is motor stop. Apart from having a reduced resolution everything seems to work. However all the tutorials online advices to use 3 pins to control L298N with the Pwm pin connected to ENB (for example this one). Why is this so? Is it not advisable to do how I did, using a single PWM pin?

If I understand it correctly, you make the motor stop by applying 50% duty cycle.
That (changing directions 500 or 1000 times a second) doesn't sound right.
Why are you doing this. Did you run out of pins? (common reason for this sort of question)
Do you know you can use the analogue pins as digital pins.
digitalWrite (A0, HIGH);
Leo..

Hello Leo

If I understand it correctly, you make the motor stop by applying 50% duty cycle.

That's correct

Why are you doing this. Did you run out of pins?

Yes I ran out of pins, I am using a Wemos D1 Mini (ESP8266).

That (changing directions 500 or 1000 times a second) doesn't sound right

If I increase the PWM frequency to 10kHz or more (possible with ESP8266), will it make a difference as the dc motor will act as a low pass filter.
Glamis

A port expander would make more sense.
Leo..