Using MCP3017AccelStepper library to run Steppers on the Accel_Stepper library

Hi I am trying to program steppers using the MCP2017 expander chip to supply the pins to run the Accel_Stepper library. I found an old library MCP3017_Stepper on git.This library also uses the Adafruit_MCP23017 library.I tried some example code and ran it on an isp 8266 computer.Had some compiler errors and modified the MCP3017_Stepper .ccp (the Adafruit_23017 must have changed from adafruit_MCP23017 to Adafruit)MCP23X17.Once the compiler errors where fixed I uploaded the program and the monitor showed the 8266 restarting continuously. I commented out the run loop and most of the Setup section. using Serial.print, isolated the error to line 26 of the ino (steppers[i].enableOutputs();). This lead to the MCP3017AccelStepper.cpp line 121 (_mcp.pinMode(pin, value);). I do not Know how to determine what the causes this to fail. Any help is greatly appreciated.
mcp23017_accelStepper_example1.ino

 #include <Wire.h>
    #include <Adafruit_MCP23X17.h>
    #include <AccelStepper.h>
    #include "MCP3017AccelStepper.h"
    
    #define STEPPER_COUNT 1

    Adafruit_MCP23X17 mcp1;

  MCP3017AccelStepper steppers[STEPPER_COUNT] = {
      // interface, step, dir, en
        MCP3017AccelStepper(AccelStepper::DRIVER, 0, 1),
//        MCP3017AccelStepper(AccelStepper::DRIVER, 4, 5, 6),
//        MCP3017AccelStepper(AccelStepper::DRIVER, 12, 11, 10),
//        MCP3017AccelStepper(AccelStepper::DRIVER, 3, 1, 2),
  };

    void setup() {
      //mcp1.begin();
  Serial.begin(115200);
  Serial.println("enter setup"); Serial.flush();
      for (int i = 0; i < STEPPER_COUNT; i++) {
        Serial.println("setMcp(mcp1)"); Serial.flush();
        steppers[i].setMcp(mcp1);
        Serial.println("setMcp(mcp1)"); Serial.flush();
//        steppers[i].enableOutputs();
        steppers[i].setMaxSpeed(150.0);
        steppers[i].setAcceleration(100.0);
        steppers[i].moveTo(200);
      }
      Serial.println("leave setup"); Serial.flush();
    }

    void loop() {
//      if (steppers[0].distanceToGo() == 0) {
//        steppers[0].moveTo(-steppers[0].currentPosition());
//      }
//
//      for (int i = 0; i < STEPPER_COUNT; i++) {
//        steppers[i].run();
//      }
    }`

End of .ino
Start of included .cpp
File MCP3017AccelStepper.h

// MCP3017AccelStepper.cpp
//
// Copyright (C) 2013 Johan Nilsson

#include "MCP3017AccelStepper.h"
#include <Adafruit_MCP23XXX.h>
MCP3017AccelStepper::MCP3017AccelStepper() {

}


MCP3017AccelStepper::MCP3017AccelStepper(uint8_t interface, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4) : _accelStepper(interface, pin1, pin2, pin3, pin4) {
  _interface = interface;
  _currentPos = 0;
  _targetPos = 0;
  _speed = 0.0;
  _maxSpeed = 1.0;
  _acceleration = 1.0;
  _sqrt_twoa = 1.0;
  _stepInterval = 0;
  _minPulseWidth = 1;
  _enablePin = 0xff;
  _lastStepTime = 0;
  _pin[0] = pin1;
  _pin[1] = pin2;
  _pin[2] = pin3;
  _pin[3] = pin4;

  if (_interface == DRIVER) {
    _enablePin = pin3;
  }

  _usingMcp = false;
  _n = 0;
  _c0 = 0.0;
  _cn = 0.0;
  _cmin = 1.0;
  _direction = DIRECTION_CCW;

  int i;
  for (i = 0; i < 4; i++) {
    _pinInverted[i] = 0;
  }
}

void MCP3017AccelStepper::setMcp(Adafruit_MCP23X17 mcp) {
  Serial.println("enter setMcp"); Serial.flush();
  _usingMcp = true;
 
   if (_usingMcp == true) {  Serial.println("true" );  } else{  Serial.println("false" ); }
  _mcp = mcp;
  Serial.println("leaving setMcp"); Serial.flush();
}

void MCP3017AccelStepper::setOutputPins(uint8_t mask) {
  uint8_t numpins = 2;
  if (_interface == FULL4WIRE || _interface == HALF4WIRE) {
    numpins = 4;
  }

  uint8_t i;
  for (i = 0; i < numpins; i++) {
    _digitalWrite(_pin[i], (mask & (1 << i)) ? (HIGH ^ _pinInverted[i]) : (LOW ^ _pinInverted[i]));
  }
}

void MCP3017AccelStepper::disableOutputs() {
  if (! _interface) {
    return;
  }
  
  setOutputPins(0); // Handles inversion automatically
  if (_enablePin != 0xff) {
    _digitalWrite(_enablePin, LOW ^ _enableInverted);
  }
}

void MCP3017AccelStepper::enableOutputs() {
  Serial.println("enter enableOutputs()"); Serial.flush();
  Serial.println("_interface "); Serial.print("_interface "); Serial.println(_interface );Serial.flush();
  if (! _interface) {
    return;
  }

  _pinMode(_pin[0], OUTPUT);
  _pinMode(_pin[1], OUTPUT);

  if (_interface == FULL4WIRE || _interface == HALF4WIRE) {
    _pinMode(_pin[2], OUTPUT);
    _pinMode(_pin[3], OUTPUT);
  }

  if (_enablePin != 0xff) {
    _pinMode(_enablePin, OUTPUT);
    _digitalWrite(_enablePin, HIGH ^ _enableInverted);
  }
}

void MCP3017AccelStepper::setEnablePin(uint8_t enablePin) {
  _enablePin = enablePin;

  // This happens after construction, so init pin now.
  if (_enablePin != 0xff) {
    _pinMode(_enablePin, OUTPUT);
    _digitalWrite(_enablePin, HIGH ^ _enableInverted);
  }
}

void MCP3017AccelStepper::_digitalWrite(uint8_t pin, uint8_t value) {
  if (_usingMcp == true) {
    _mcp.digitalWrite(pin, value);
  } else {
    digitalWrite(pin, value);
  }
}

void MCP3017AccelStepper::_pinMode(uint8_t pin, uint8_t value) {
  Serial.println("enter _pinMode(uint8_t pin, uint8_t value)"); Serial.flush();
  if (_usingMcp == true) {
    Serial.print("pinMode(pin, value)"); Serial.print(pin); Serial.print(' ' ); Serial.println(value );
    _mcp.pinMode(pin, value);
  } else {
    pinMode(pin, value);
  }
}

end of .cpp start included .h file

// MCP3017AccelStepper.h
//
// MCP23017 I2C AccelStepper library for Arduino
//
// Extends the Arduino AccelStepper library to add support for the MCP23017 I2C I/O expander.
//
// License GPL V2, same as AccelStepper (http://www.airspayce.com/mikem/arduino/AccelStepper/)
//
// Author Johan Nilsson (http://www.markupartist.com)
// Copyright (C) 2013 Johan Nilsson

#ifndef MCP3017AccelStepper_h
#define MCP3017AccelStepper_h

#include <stdlib.h>
#include <Arduino.h>
#include <Wire.h>
#include <AccelStepper.h>
#include <Adafruit_MCP23X17.h>

class MCP3017AccelStepper : public AccelStepper {
  public:
  MCP3017AccelStepper();
  MCP3017AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5);
  void setMcp(Adafruit_MCP23X17 mcp);
  void setOutputPins(uint8_t mask);
  void disableOutputs();
  void enableOutputs();
  void setEnablePin(uint8_t enablePin);
  
private:
  AccelStepper _accelStepper;
  Adafruit_MCP23X17 _mcp;
  bool _usingMcp;
  void _digitalWrite(uint8_t pin, uint8_t value);
  void _pinMode(uint8_t pin, uint8_t value);
};

#endif

end of .h file start of monitor messages

setMcp(mcp1)
enter setMcp
true
leaving setMcp
setMcp(mcp1)
enter enableOutputs()
_interface 
_interface 1
enter _pinMode(uint8_t pin, uint8_t value)
pinMode(pin, value)0 1

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3):
epc1=0x40206164 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40203310 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffd80 end: 3fffffd0 offset: 0150
3ffffed0:  feef0000 feefeffe feefeffe 40204738  
3ffffee0:  3fffff30 fffffffc feefeffe 40201911  
3ffffef0:  40202c30 00000000 3fffff68 40201965  
3fffff00:  00000001 00000000 00000001 40201778  
3fffff10:  00000000 00000001 0000000a 40202ea8  
3fffff20:  00000000 00000000 0000000a 00000003  
3fffff30:  0101000c 00000000 3ffe85d8 00000000  
3fffff40:  00000000 00000000 40203300 00000003  
3fffff50:  01010000 3ffe8800 3ffee7ac 00000000  
3fffff60:  3fffff20 00000001 3fffff40 40200001  
3fffff70:  00000000 00000000 3ffee7ac 4020121c  
3fffff80:  3ffe8811 0000000a 3ffee7ac 3ffee814  
3fffff90:  3ffe8811 3ffee7ac 3ffee588 402012a5  
3fffffa0:  3ffe884a 3ffee588 3ffee7ac 40201434  
3fffffb0:  3fffdad0 00000000 3ffee800 40203460  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100ca9  
<<<stack<<<

You are writing about MCP3017 in the title you are writing about MCP2017 in the text

If you are programming that lazy you type numbers then it is no wonder that things don't work

I guess you mean MCP23017. These are I2C-chips which have a rather slow maximum frequency and now you want to create stepper-pulses that require extremely tight timed pulsetiming? Two very different worlds collide.

You should explain why you think it is nescsessary to use I2C-IO-expanders to drive steppermotors.

I am pretty sure that there are mutliple different solutions to what you want to do as the final purpose of rotating steppermotors.

Thank you for responding. Sorry about the MCP23017 chip spelling mistake. The reason I am trying to use the I2C-IO-expanders is that I want to drive 5 steppers using A-4988 drivers which require 2 pins each. The 1. MCP3017AccelStepper # README.md states " With this library AccelStepper can be used to control steppers using a MCP23017 I/O Expander over I2C interface. This requires only two pins to be used A4 SDA and A5 SCL on the Arduino Uno. MCP23017AccelStepper extends AccelStepper which means that all the functionality of AccelStepper is still there." I realize that the steppers might not rotate fast enough, so this is an experiment to test that. My hope is that someone can help me fix the library so that I can run the test.

Without access to ESP8266 I don;t think I could reproduce the fault. Exception 3 is a rather general "address error", the address being 0x40203310, so it is not a NULL pointer.

Other things it could be are an invalid pointer reference, a stack overflow etc. I'm not familiar with the ESP8266 memory layout.

With multiple libraries involved, there is quite a stack of code involved and without a debugger could be hard to track down. I would try running the libraries separately and building up functioinality, even if it does not initially perform your target goal.

So for example, run AccelStepper directly and check that works, then use MCP23x17 library to toggle pins directly. Also I would check the compiler errors were properly fixed; it's quite easy to find a workaround to avoid an error but actually causes some other bug.

Thanks I will keep looking for error

You should post even more information about your project.
What is the final purpose of rotating the steppermotors?

some really wild guessings:
will your 5 steppermotors wave flags on animated figures?
will your 5 steppermotors drive 5 conveyor-belts that must move in perfect sync to make the whole machine work?
Will your 5 steppermotors be used to drive a 4-wheel robot that can turn his head?

So one question is if the steppermotors will need to be in perfect sync with each other or if smaller deviations when certain motors start / stop is acceptable.

It might even be - depending on your application that a different type of motor will be good suited.