hello,gays,is there any sample code to drive mcp23s17 on teensy 4.0?

bigfanofiot

Member
I had got one mcp23s17,but it hard for me to drive it using SPI on teensy 4.0,can anyone give me some examples?

thanks very much!
 
You can find libraries in Arduino IDE, like this:

1701529395118.png
 
After you install any of these libraries, click File > Examples and scroll down the long list to look for your freshly installed library's examples.

Some of these libraries give multiple ways to access the hardware. You want "hardware SPI", which is usually the default way.

Beware of "Software SPI", where you can specify all the pins. Often this is written for slower boards and Teensy 4.0 can run much too fast. Often the examples that come with these libraries have multiple ways to access the chip, usually with comments the code to explain. Read those comments and delete any Software SPI config and go with the Hardware SPI config, so you get reliable speed.

Hardware SPI works the same way on virtually all Arduino compatible boards, including Teensy, so any of these libraries with config to use Hardware SPI should work fine on Teensy 4.0.
 
After you install any of these libraries, click File > Examples and scroll down the long list to look for your freshly installed library's examples.

Some of these libraries give multiple ways to access the hardware. You want "hardware SPI", which is usually the default way.

Beware of "Software SPI", where you can specify all the pins. Often this is written for slower boards and Teensy 4.0 can run much too fast. Often the examples that come with these libraries have multiple ways to access the chip, usually with comments the code to explain. Read those comments and delete any Software SPI config and go with the Hardware SPI config, so you get reliable speed.

Hardware SPI works the same way on virtually all Arduino compatible boards, including Teensy, so any of these libraries with config to use Hardware SPI should work fine on Teensy 4.0.
thanks,I will have a try
 
Back
Top