Motor Shield R3 and SF xbee shield not working

Hi

As the title says I am trying to stack a motor shield r3 and a sparkfun xbee shield SparkFun XBee Shield - WRL-12847 - SparkFun Electronics on top of a mega 2560 r3. But it is not working. I am trying to run the following sketch.

If I remove the xbee shield then my motors run the way they should but if I leave the xbee shield on the motors simply dont turn.

This same setup is working with a DFrduino motor shield.

Can someone help me with this.

/*
 #include "Arduino.h"
#include <QuadratureEncoder.h>

// Left Motor Encoder uses external interupts 2 and 3 on pins 20 and 21
QuadratureEncoder encoderMotorL(21,20); //for all others
// Right Motor Encoder uses external interupts 5 and 4 on pins 18 and 19
QuadratureEncoder encoderMotorR(18, 19);

int PwmMotorL = 3, PwmMotorR = 11;
int DirMotorL = 12, DirMotorR = 13;
long encL =0, encR =0;

void setup()
{
          //Initialize Serial Link
          //##################################################    
    Serial2.begin(9600);
          //Set Initial Encoder Positions
          //##################################################        
    encoderMotorL.setPosition(0);
    encoderMotorR.setPosition(0);
          //Assign Interrupts for Encoder A and B
          //##################################################        
    attachInterrupt(3, HandleMotorLInterruptA, CHANGE);  // Pin 20
    attachInterrupt(2, HandleMotorLInterruptB, CHANGE);  //Pin 21
    attachInterrupt(5, HandleMotorRInterruptA, CHANGE); // Pin 18
    attachInterrupt(4, HandleMotorRInterruptB, CHANGE); // Pin 19
          //Initialize motor spin direction
          //##################################################        
    digitalWrite(DirMotorL, LOW); digitalWrite(DirMotorR, LOW);
    analogWrite(PwmMotorL,255); analogWrite(PwmMotorR,255);
    Serial2.print("Running \n");
}

void loop()
{
  encL = encoderMotorL.getPosition();encR = encoderMotorR.getPosition();
  Serial2.print("\n");
  Serial2.print(encL);Serial2.print("\t");Serial2.print(encR);
  delay(5000);
}
        // Interrupt service routines for motor 1 quadrature encoder
        //##########################################################
void HandleMotorLInterruptA()
{  encoderMotorL.OnAChanged(); }
void HandleMotorLInterruptB()
{  encoderMotorL.OnBChanged(); }
        // Interrupt service routines for motor 2 quadrature encoder
        //##########################################################      
void HandleMotorRInterruptA()
{  encoderMotorR.OnAChanged(); }
void HandleMotorRInterruptB()
{  encoderMotorR.OnBChanged(); }

Thank you for your help
--ksp

Hi

I just removed the header from pin 8 - AREF on the xbee board and it started working.

--ksp