MC33926 & Arduino: Issues using PWM on D pins

I’ve been trying to PWM through the D pins of the MC33926 motor driver using Ardunino Duemilanove.
I can successfully PWM through the IN pins and the motor and shield seems to be working fine if I ignore the D pins and only use the IN pins. However, I’d like to PWM through the D pins.
Here are my connections:
EN - 2
SF - 3
D1 - 11 (PWM)
D2 - 10 (PWM)
IN1 - 9 (PWM)
IN2 - 6 (PWM)

VIN - 12V power supply
OUT2 - Motor (+)
OUT1 - Motor (-)

All my grounds are connected together to make a common ground.

Here’s my simplified code:

int ledPin =  13;    
int enPin = 2;    
int d1Pin = 10;   
int d2Pin = 11;   
int in1Pin = 9;   
int in2Pin = 6;
int sfPin = 3;

void setup()   {                
  pinMode(ledPin, OUTPUT);
  pinMode(enPin, OUTPUT);  
  pinMode(d1Pin, OUTPUT);
  pinMode(d2Pin, OUTPUT);
  pinMode(in1Pin, OUTPUT); 
  pinMode(in2Pin, OUTPUT);
  pinMode(sfPin, INPUT);  

void loop()
  digitalWrite(enPin, HIGH);
  digitalWrite(in1Pin, HIGH);
  digitalWrite(in2Pin, LOW);
  digitalWrite(d1Pin, LOW);
  analogWrite(d2Pin, 100);

I’m simply trying to control the motor with PWM through D2 pin, but when I run this code, the motor just runs at its top speed and the voltage at OUT2 is 12V.

I have tried many different things, like changing the HIGH/LOW of the different pins in all possible combinations (tedious!!).

I’ve attached pictures of my setup:

It seems as though it doesn’t matter whether the D pins are low or high or whatever combination.
I’d be happy to explain further exactly what I’ve tried.

- Mars

Hello, Mars.

I did not see anything obviously wrong with your setup or code. What values did you try for the PWM value in analogWrite()? If you have access to an oscilloscope, could you verify that there are valid PWM signals coming from pins 10 and 11? Could you also post the original code you had working that uses IN1 and IN2 as PWM inputs?

- Jeremy