Closed steeley closed 1 year ago
I don't see this issue when setting pins high. From my experience, pins that are set HIGH stay high until either they are set LOW or there is a power-down.
This is the code I used to test the pins...
MCP23S08 expander(CS_PIN);
void setup() { SPI.begin(); expander.begin(); for (uint8_t pin = 0; pin < 8; pin++) { expander.pinModeIO(pin, OUTPUT); } expander.setOutputStates(B00000000); }
void loop() { expander.digitalWriteIO(0, HIGH); delay(1000); expander.digitalWriteIO(3, HIGH); delay(1000); }
Function digitalWriteIO
does a read-modify-write, reading current state from the MCP itself, rather than saving the expected settings locally. If your pins get reset, it seems likely your return channel (MCP -> MCU) is corrupted.
Doing a read-modify-write is simpler, more transparent and may be preferable than local state keeping if you have multiple instances controlling the MCP. OTOH, as seen, it is more vulnerable to read disturbances.
Moved to new issue...
@fdxrate Perhaps it would be best to discuss this in a separate issue? Please create a separate issue and we will discuss it there.
BTW, block quotes are delimited with ```
, and you can start the block with ```c++
to enable c++ syntax highlighting (use Preview to verify).
Sorry for the late answer (I wrongly assumed Github would send me a notification for new issues/PRs).
Can I close this issue or are there questions left not covered in the new one?
I believe there are no open questions.
Tested on Teensy 3.2, Arduino 1.8.13
Seems digitalWriteIO only works on 1 pin at a time. Is this correct?
if you set pin 0 high for example, and then set pin pin 4 high, pin 0 goes low.
Only this function seems to work for setting multiple pins: // set pin 0 and 4 expander.setOutputStates(B00010001);