I am writing a library for the MCP23S17 8x port expanders being tested on a UK board made for the rasbpi but I have it wired to the Teensy4.
When I do multiple SPI calls, after I deassert the line, I have endTransaction inbetween each call. I figure, if it's within the same function toggling the GPIO, I'd remove the additional beginTransaction and endTransaction in between. However when I do this the GPIOs don't seem to change state (on expanders) because the register didn't update (debug output shows nothing changed on port). Leaving beginTransaction and endTransaction between calls to the same chip works fine. Is it because the GPIO is toggling too fast that when I introduce additional beginTransaction and endTransaction in between it allows the chip to see the assertion signal?
Example:
When I do multiple SPI calls, after I deassert the line, I have endTransaction inbetween each call. I figure, if it's within the same function toggling the GPIO, I'd remove the additional beginTransaction and endTransaction in between. However when I do this the GPIOs don't seem to change state (on expanders) because the register didn't update (debug output shows nothing changed on port). Leaving beginTransaction and endTransaction between calls to the same chip works fine. Is it because the GPIO is toggling too fast that when I introduce additional beginTransaction and endTransaction in between it allows the chip to see the assertion signal?
Example:
Code:
[COLOR="#008000"]bus->beginTransaction(SPISettings(speed,MSBFIRST,SPI_MODE0));[/COLOR] /* read port register */
::digitalWriteFast(chipSelect, LOW);
bus->transfer16(((0x41 | (i << 1)) << 8) | 0x12);
uint16_t data = bus->transfer16(0xFFFF);
::digitalWriteFast(chipSelect, HIGH);
[COLOR="#FF0000"]bus->endTransaction();[/COLOR]
data = (data & ~(1UL << pin)) | (level << pin); /* set new pin state */
[COLOR="#FF0000"]bus->beginTransaction(SPISettings(speed,MSBFIRST,SPI_MODE0));[/COLOR] /* write port register */
::digitalWriteFast(chipSelect, LOW);
bus->transfer16(((0x40 | (i << 1)) << 8) | 0x12);
bus->transfer16(data);
::digitalWriteFast(chipSelect, HIGH);
[COLOR="#008000"]bus->endTransaction();[/COLOR]
Last edited: