Teensy 3.2 and Multiple SPI Interfaces

Status
Not open for further replies.

dmilrtime

Member
Hello All,

Longtime Embedded Systems Developer (since 1989) newbie to Arduino development.

I am using the Teensy 3.2 and the Teensyview OLED Display module (really nice little display). In addition I am also using the ADNS-9800 Laser Motion Sensor: https://www.tindie.com/products/jkicklighter/adns-9800-laser-motion-sensor/

Both devices use SPI to communicate however one device needs LSB first and Mode 3 and the doesn't. So I was thinking since the Teensy 3.2 has multiple SPI ports I would simply use one SPI port for one device and a different SPI port for the other device.

SPI0 = Teensyview
SPI1 = ADNS-9800

How do I initialize a second instance of SPI functions and choose a different SPI port? I see it as an option in the SPI.h file but I don't see how I actually select one of the other SPI ports.

If anyone has a sample snippet of code showing haw this is done that would be great.

Thanks,
Dave
 
If my memory is serving me correctly: The Teensy 3.2 only has one hardware SPI port.
T-LC has two
T3.5/3.6 have three.


Which matches what is shown on the page: https://www.pjrc.com/teensy/techspecs.html

Well, I completely missed that on the Spec sheet. I kept looking at the SPI.h file and saw under the Teensy section it referenced up to 3 SPI ports. So I made an assumption which after all these years I should know better.

Thanks, I guess I will be looking at using the Software SPI library I found. Since the display is one way in communications I just need simple SPI functionality. And can use the built-in one for the ADNS-9800.
 
Another approach is to use SPI transactions. Each transaction can have different SPI settings (LSB/MSB, speed, etc.). It does depend on your devices properly releasing the CS/DC pins.

The Teensy SPI page documents the transaction support:

Some display and ethernet devices use the special hardware CS pins to optimize the SPI using DMA, but I don't think the TeensyView does.
 
Status
Not open for further replies.
Back
Top