VNH5019 motor driver shield without library

I'm trying to use the VNH5019 dual motor driver without the library. The following sample code works as expected.

#include "DualVNH5019MotorShield.h"

DualVNH5019MotorShield md;

void stopIfFault()
{
  if (md.getM1Fault())
  {
    Serial.println("M1 fault");
    while(1);
  }
  if (md.getM2Fault())
  {
    Serial.println("M2 fault");
    while(1);
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println("Dual VNH5019 Motor Shield");
  md.init();
}

void loop()
{
  for (int i = 0; i <= 400; i++)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = 400; i >= -400; i--)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = -400; i <= 0; i++)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = 0; i <= 400; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = 400; i >= -400; i--)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
  
  for (int i = -400; i <= 0; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
}

I would like to use the motor driver without the library. I used the attached truth table on pg 14 of the data sheet for this code:

int M1INA = 2;
int M1INB = 4;
int M1EN = 6;
int M2INA = 7;
int M2INB = 8;
int M1PWM = 9;
int M2PWM = 10;
int M2EN = 12;

void setup() {

  pinMode(M1INA, OUTPUT);
  pinMode(M1INB, OUTPUT);
  pinMode(M1EN, OUTPUT);
  pinMode(M2INA, OUTPUT);
  pinMode(M2INB, OUTPUT);
  pinMode(M1PWM, OUTPUT);
  pinMode(M2PWM, OUTPUT);
  pinMode(M2EN, OUTPUT);
}

void loop() {
  digitalWrite(M2EN, HIGH);    //enable left motor
  digitalWrite(M1EN, HIGH);    //enable right motor
  digitalWrite (M1INA, HIGH);  //forward
  digitalWrite (M1INB, LOW);
  analogWrite(M1PWM, 255);  
  digitalWrite (M2INA, HIGH);   //forward
  digitalWrite (M2INB, LOW);
  analogWrite(M2PWM, 255);

}

Unfortunately the result is that the motors don't turn and sound like they are stalled out even though there is no load on them.

I have looked for sample code without using the library on the data sheet, user guide, this forum, google, instructables, and Pololu's forum. Anybody used this or something similar without the library? I attached the truth table from the data sheet.

I'm using 6 AA NiMH batteries for the motor power supply and a 9V battery for the arduino supply.

I may have found the problem. I think the rechargeable NiMH batteries don't supply enough power. When I disconnected these two motors and plugged in these much smaller motors, the sketch seems to work as expected. The motors I want to use are 6V motors, which apparently the NiMH batteries can't supply enough current. I'm actually using 6 aa batteries. They average 1.2V for NiMH x 6 = 7.2V. Any better suggestions for better batteries?

Did you measure the battery voltage while trying to run the motors?
Are the batts full charged?

This motor needs a lot od Amos to run, remember that start current is higher than normal and if You have two of them, i dont think, that AAA batteries could handle IT, but i can be wrong. Have You an opportunity to change for a while batteries to acumulator or something which can give about 6/7Amps surely? Firstly try with one motor and a little bit better power suplyer

High current means SLA / LiPo / LiFePO4 are your options.