Skip to content

With 3 chips, the 3rd chip appears to function as an AND gate of the 1st two chips #1

@riverwilliams94

Description

@riverwilliams94

Here's my code, modified from the example code provided

#include <MCP23S17.h>

#ifdef __PIC32MX__
// chipKIT uses the DSPI library instead of the SPI library as it's better
#include <DSPI.h>
DSPI0 SPI;
#else
// Everytying else uses the SPI library
#include <SPI.h>
#endif

const uint8_t chipSelect = 15 ;

// Create an object for each chip
// Bank 0 is address 0
// Bank 1 is address 1.
// Increase the addresses by 2 for each BA value.

MCP23S17 Bank1(new SPIClass(HSPI), chipSelect, 0);
MCP23S17 Bank2(new SPIClass(HSPI), chipSelect, 1);
MCP23S17 Bank3(new SPIClass(HSPI), chipSelect, 2);


void setup() {
  Serial.begin(115200);
  Bank1.begin();
  delay(50);
Bank2.begin();
delay(50);
  Bank3.begin();
  delay(50);
  for (int i = 0; i < 16; i++) {
    Bank1.pinMode(i, OUTPUT);
    delay(50);
   Bank2.pinMode(i, OUTPUT);
   delay(50);
    Bank3.pinMode(i, OUTPUT);
    delay(50);
  }
    for (int i = 0; i < 16; i++){
   Bank1.digitalWrite(i,  1);
   delay(50);
    Bank2.digitalWrite(i, 1);
    delay(50);
    Bank3.digitalWrite(i, 1);
    delay(50);
  }
}
void loop(){}

The thing is, Bank3.digitalWrite(i, 1) does not appear to work. Instead, it follows and logic of the first 2. Ex: if Bank1.digitalWrite(i,1) and Bank2.digitalWrite(i,1) then Bank3's pins are pulled high. If either bank1 or bank2's pins are written low, then bank3's pins are pulled low, regardless of what Bank3's digitalWrite says.

I have triple checked my wiring and don't notice any issues

Also, I'm running this code on an ESP32 Devkit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions