Teensy SPI CS Pins

Status
Not open for further replies.

Kian

Active member
On the Teensy Pin Assignment diagram, I see several CS pins (CS0, CS1, CS2 and CS3). Does it mean that only these pins can be used to connect to other Slave devices? Or they all share the same signal?
 
There are 2 ways to create the chip select signals.

#1: Direct pin manipulation. All existing code uses this approach. Any digital pin can be used. It does not matter if one of the CS0, CS1, CS2, etc. The code merely controls a digital pin the normal way, so any pin be used. On Teensy 2.0 and normal Arduino boards, this is the only way. All the code which exists today was designed for those board, so none of it uses the other way.

#2: Automatic chip select control by the SPI port. Today, I am not aware of any library or example using this way. Eventually, some libraries may begin using this approach. When they do, one of the 5 special pins must be used. Each is a different signal, so in theory up to 5 different SPI devices can be connected this way.
 
My adaptation of the Adafruit ST7735 library already uses hardware CS in a limited fashion.

I did have it using hardware CS for the actual CS of the LCD, but that didn't work with SdFat, so I abandoned that and went to direct-pin.

However, I do use a hardware CS pin for the "D/C" (data/command) pin. This pin is used to differentiate data vs commands via SPI, and they are often interleaved. The reason I am doing this is to allow the FIFO to contain both data and command bytes as needed; otherwise I'd have to flush the FIFO between each one, and that would slow things down a lot. (Each FIFO entry has a set of CS bits for that specific transfer, so it takes care of asserting the correct ones as it steps through the FIFO, which would be more or less impossible to do reliably in software).

So, while it's not technically a chip-select, this is certainly already in use.
 
Status
Not open for further replies.
Back
Top