Using PWM with L298N

I'm trying to get two dc motors speed control working using PWM. Sample code tells me that I could send digital HIGH and LOW to IN1, IN2, IN3 and IN4 on the L298N board to control the direction. And send PWM signal to ENA and ENB to control the speed. But it won't work. Sending PWM on ENA or ENB only turns the motors on and off on full speed. But I can control the speed by sending PWM to IN1, IN2, IN3 and IN4 instead. What am I doing wrong?

This code turns the motor just on or off when I twist a pot:

  analogWrite(in1, 255);
  analogWrite(in2, 0);
  analogWrite(enA, analogRead(pot) / 4);

This code on the other hand lets me control the speed with the pot:

  analogWrite(in1, analogRead(pot) / 4);
  analogWrite(in2, 0);
  digitalWrite(enA, HIGH);

A good working example of controlling two DC motors with PWM is HERE

Note: Not all Arduino pins can do PWM!

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

If you're going to analogWrite the enable pins, you only need to digitalWrite in1, in2, in3, in4.
Check fig. 6 on the datasheet:

And make sure there is not a jumper on your motor board tying the enable pins HIGH.