Teensy 4.0 SPI questions.

Status
Not open for further replies.

OhioJim

Well-known member
Is it possible to use more than one of the SPI ports at the same time?

Although the info here on PJRC shows how to select alternate ports, I have not found an example of that. All the examples use just the primary port.

Is it necessary to define the pins as input or output, or do the SPI functions do that?
 
Simple answer is Yes: You can use all three at the same time if you want.

To use the main SPI pins 11-13 (plus maybe CS of 10) you use the SPI object.
To use the SPI1 pins (SCK1=27, MOSI1=26, MISO1=11 and if needed CS1=0) you use the SPI1 object
To use the SPI2 pins (on the SDCard pin setup(pins 34-37) use the SPI2 object.

If you do something like: SPI1.begin() it will setup to use the SPI1 pins (SCK, MOSI, MISO) and will configure them to be in the right mode. If your actual code uses the Hardware CS capabilities (very little software actually does), than there is a method to do that as well, most of the time software just uses any digital pin and controls with digitalWrite like statements.
 
Thanks, KurtE. I will give that a try.

I did not see anything about SPI1.begin() or SPI2.begin() in any of the examples or tutorials. And the header file has so many parameters and options that it is hard to tell what is needed.
 
@KurtE

I tried using SPI1 as you suggested!

I have a pair of 3 axis analog output accelerometers connected to an ADS1256. I made the changes to my test sketch and it is now happily spitting out numbers that make sense.
 
Status
Not open for further replies.
Back
Top