Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 4.0 SPI questions.

  1. #1

    Teensy 4.0 SPI questions.

    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?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    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.

  3. #3
    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.

  4. #4

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts