ST7565 + MCP23S17 / Conflict?

Hi!

I’m using multiplexing with two MCP23S17s and a ST7565 GLCD.

I can get each to respond as expected on their own, but together has turned in to a bit of a minefield!

Here’s my code:

/*

PIN SETUP

ST7565:

CS   - (7)
RST  - (8)
A0   - (9)
SID  - (11)
SCLK - (13)


MCP23S17:

CS   - (10)
MOSI - (11)
MISO - (12)
SCLK - (13)

*/



#include <SPI.h>
#include <MCP23S17.h>
#include "ST7565.h"


MCP onechip(0);
MCP twochip(1);


ST7565 glcd(11, 13, 9, 8, 7);


void setup() {

  onechip.pinMode(0B0000000000000000);
  twochip.pinMode(0B1111000011111111);
  onechip.pullupMode(0B0000000000000000);
  twochip.pullupMode(0B0000000011110000);

  glcd.begin(0x18);
  glcd.clear();
  delay(100);

  Serial.begin(115200);

}

void loop() {


  onechip.digitalWrite(0B1111000111111111);
  twochip.digitalWrite(0B1111000011111111);


  glcd.drawstring(0, 0, "!!!TEXT!!!");
  glcd.display();
  glcd.clear();
  delay(100);
}

I can call the libs etc, but as soon as I set up ‘MCP name_Of_IC’ (MCP onechip(0) / MCP twochip(1)) I get a change of colour, but lose the printout on the LCD.

I thought this may be something to do with the clock divider in ‘MCP23S17.cpp’. but changingn this has no effect.

Does anyone have any ideas as to how to get this working?

I may have missed something obvious, however, I can now feel my brain leaking out of my ear…

Thanks in advance for any help!

ST7565 glcd(11, 13, 9, 8, 7);

Pins 11 and 13 are part of the SPI interface. They are NOT available for you to attach your LCD to, while using the SPI interface.

OK. Thank you.

I assumed I could use the same clock and data out.

I will try it with different pins.

You can if they are both using the SPI bus. It isn't clear from what you've written whether or not that is true.

I am currently using the default libs for both.

I was told that by ditching the standard lib and bitbanging the outputs I could get a near x10 refresh rate, as things look a bit sluggish when it comes to bitmaps etc, so will be trying this out in the next few days hopefully.

Could I move everything back up with this approach?

I'm looking in to rooting out all the digitalWrites generally, but was told that software serial may be the way forward.

I also have an SD attached, and it's all happily working, but I have now run out of dynamic memory (I've still got a fair bit of room in the program memory).

I'd also like to free some more pins up, so will have a look around for anything SD/LCD/Expander related to see if I can get this all working a bit faster/more responsive.

I think I saw something about using the SD as RAM/additional memory.

Longer term I'll probably end up moving everything up to the DuE anyway, otherwise it looks like I'm going to be using lots of dedicated 328s..

I'm looking to keep things all as streamlined as possible, so, any suggestions on the combination of these would be appreciated!