RobTillaart / MCP23S17

Arduino library for SPI based MCP23S17 16 channel port expander
MIT License
27 stars 11 forks source link

improve performance 16 pins interface #24

Closed RobTillaart closed 1 year ago

alx-uta commented 1 year ago

@RobTillaart just had a look at the code.

I can see what you did, instead of reading or writing twice, you'll only do it once.

That's really good.

I'll run a few tests and I'll share the results.

alx-uta commented 1 year ago

Test results:

Software SPI

true
HWSPI: 0

SPISpeed:   1000000

time in microseconds

TEST digitalWrite(0, value):    63.38
TEST digitalWrite(pin, value):  45.69
TEST digitalRead(pin):  32.00

TEST write8(port, mask):    33.00
TEST read8(port):   34.50

TEST write16(mask): 39.50
TEST read16():  39.50

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   2000000

time in microseconds

TEST digitalWrite(0, value):    60.88
TEST digitalWrite(pin, value):  61.06
TEST digitalRead(pin):  31.62

TEST write8(port, mask):    32.00
TEST read8(port):   31.50

TEST write16(mask): 31.50
TEST read16():  31.50

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   4000000

time in microseconds

TEST digitalWrite(0, value):    60.88
TEST digitalWrite(pin, value):  61.06
TEST digitalRead(pin):  31.62

TEST write8(port, mask):    32.00
TEST read8(port):   31.50

TEST write16(mask): 31.50
TEST read16():  31.50

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   8000000

time in microseconds

TEST digitalWrite(0, value):    60.88
TEST digitalWrite(pin, value):  61.06
TEST digitalRead(pin):  31.62

TEST write8(port, mask):    32.00
TEST read8(port):   31.50

TEST write16(mask): 31.50
TEST read16():  31.50

VAL1:   0
VAL8:   170
VAL16:  43690

Hardware SPI:

true
HWSPI: 1

SPISpeed:   1000000

time in microseconds

TEST digitalWrite(0, value):    85.87
TEST digitalWrite(pin, value):  62.94
TEST digitalRead(pin):  43.94

TEST write8(port, mask):    45.00
TEST read8(port):   47.00

TEST write16(mask): 45.00
TEST read16():  45.00

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   2000000

time in microseconds

TEST digitalWrite(0, value):    56.31
TEST digitalWrite(pin, value):  56.31
TEST digitalRead(pin):  29.12

TEST write8(port, mask):    29.50
TEST read8(port):   29.50

TEST write16(mask): 23.50
TEST read16():  23.50

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   4000000

time in microseconds

TEST digitalWrite(0, value):    42.63
TEST digitalWrite(pin, value):  42.63
TEST digitalRead(pin):  22.19

TEST write8(port, mask):    22.50
TEST read8(port):   22.50

TEST write16(mask): 16.50
TEST read16():  16.50

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   8000000

time in microseconds

TEST digitalWrite(0, value):    35.63
TEST digitalWrite(pin, value):  35.63
TEST digitalRead(pin):  18.56

TEST write8(port, mask):    19.00
TEST read8(port):   19.00

TEST write16(mask): 13.00
TEST read16():  13.00

VAL1:   0
VAL8:   170
VAL16:  43690

SPISpeed:   10000000

time in microseconds

TEST digitalWrite(0, value):    34.31
TEST digitalWrite(pin, value):  34.31
TEST digitalRead(pin):  17.87

TEST write8(port, mask):    18.00
TEST read8(port):   18.00

TEST write16(mask): 12.00
TEST read16():  12.00

VAL1:   0
VAL8:   170
VAL16:  43690

done...

It looks really good, thx for updating it! :)