Hi Great Ones
Sorry if this may sound trivial but i had it already, been done searching and doing stuffs but I'm unable to properly reset programmatically the MCP23S17, so my setup is just simple, arduino uno having SPI lines connected properly to the MCP23S17, connected hardware addresses pins all to ground and reset pin to vcc. I had successfully controlled it as an ouput expander (on leds) w/o library, just simple SPI transaction of opcode -> register address -> data (ofc, done some spi initial setups like spi parameters, etc.)
Now i wanted to reset it programmatically after doing some output states on leds, now searched out on how other chips are being reset specially this is chip has a low-enable reset like on atmega328 so for me to reset it, i simply put a pull up resistor to the reset pin where as it still functions great but then whenever i try to put or input a logic low / gnd after pull up resistor (as image below), the chip resets but unable to operate again unless i restart my arduino uno, why is that?
tried to search a lot of forum, on its datasheet even its libraries but nothing mention on how to reset the chip externally via programmatically controlled input on it. Please help
PS: my arduino code i use. (it's just a simple serial input via keyboard on the serial monitor which logic and operation works fine not until i tried to connect the pin to the mcp23s17's reset to actually sent out signal low)
#include <SPI.h>
uint8_t leds[] = {0x01, 0x02};//, 0x04};//, 0x08};
int cs = 10;
int reset = 8;
String cmd = "";
SPISettings spi(SPI_CLOCK_DIV2, MSBFIRST, SPI_MODE0);
void setup() {
Serial.begin(9600);
SPI.begin();
pinMode(cs, OUTPUT);
pinMode(reset, OUTPUT);
SPI.beginTransaction(spi); //DISABLE SEQOP (Sequential Operation)
digitalWrite(cs, LOW);
SPI.transfer(0x40);
SPI.transfer(0x05);
SPI.transfer(0x20);
digitalWrite(cs, HIGH);
SPI.endTransaction();
SPI.beginTransaction(spi); //Configure I/O Direction to Output
digitalWrite(cs, LOW);
SPI.transfer(0x40);
SPI.transfer(0x00);
SPI.transfer(0x00);
digitalWrite(cs, HIGH);
SPI.endTransaction();
SPI.beginTransaction(spi); //reflects the same logic state of the input pin.
digitalWrite(cs, LOW);
SPI.transfer(0x40);
SPI.transfer(0x01);
SPI.transfer(0x00);
digitalWrite(cs, HIGH);
SPI.endTransaction();
digitalWrite(cs, HIGH);
digitalWrite(reset, HIGH);
Serial.println("Start");
}
void loop() {
if (Serial.available() != 0) {
while (Serial.available() != 0) {
char c = Serial.read();
cmd += c;
delay(1);
}
Serial.println(cmd);
if (cmd.equals("1")) {
for (int c = 0; c < 3; c++) {
for (int i = 0; i < sizeof(leds); i++) {
SPI.beginTransaction(spi);
digitalWrite(cs, LOW);
SPI.transfer(0x40);
SPI.transfer(0x13);
SPI.transfer(leds[i]);
digitalWrite(cs, HIGH);
SPI.endTransaction();
delay(500);
}
}
} else if (cmd.equals("0")) {
digitalWrite(reset, LOW);
digitalWrite(reset, HIGH);
Serial.println("This is successfully printed upon input 0 at serial monitor");
}
cmd = "";
}
}