Go Down

Topic: Understanding SPI (Read 826 times) previous topic - next topic

SirPoonga

I am trying to understand how SPI works.  It looks like you can hook up more than one SPI device and have a way to address each device.  It seems the device needs a CS pin that you connect to any digital pin ont he arduino to set that device as "active."  

However, how does this work if a device doesn't have a CS pin?  Like trying to control the TLC5947 and something else like an SPI LCD.

Ran Talbott

Quote
However, how does this work if a device doesn't have a CS pin?

Not very well.

"SPI" is used to describe a variety of serial,  shift-register-like interfaces,  not just the 4-wire one designed by Motorola.

The TLC5947 is one of those that uses "SPI" merely as an abbreviation,  not a reference to the Moto/AVR/Arduino standard.

Another thing to watch out for is that some (all??) of the Wiznet-based Ethernet shields don't implement CS properly,  so you'll have problems if you try to mix them with another SPI device.  A forum search will turn up at least one thread started by someone who discovered this the hard way   >:(

A forum search should also turn up threads by folks who've gotten the TLC5947 working (I'm pretty sure I've seen some,  but I could be mistaken).

Ran

SirPoonga

So if I use the TLC5947 I wouldn't be able to use those pins for other hardware that needs them (at least the serial pins)

I thought I saw somewhere how to use TLC serially with any pins.

Celso Fraga

Who says this chip is SPI?

It uses a simple data/clock serial bus, like many other shift registers do.

I suggest you to use any other two pins and shiftOut(), then you'll get the results you want.

kg4wsv

SPI is a special shift register.

Take a barrel shifter, usually 16 bits wide, and chop it in half.  8 bits are in the microcontroller, 8 in the peripheral.  Two wires (data in/data out, aka MISO/MOSI) connect the two halves of the register, and the clock is fed to both halves (SCK is the line providing this to the peripheral's half).

One final connection is the chip select (aka SS aka CS), which controls the output of the external half of the shift register (MISO), causing it to be in a high impedance (i.e. infinite resistance/open circuit/electrically disconnected) state.  This bit of magic allows multiple peripherals to be connected to common MISO/MOSI/CSK lines, and lets the microcontroller choose which one it is connected to.

This may not be a 100% accurate simplification, but it helps me understand it.

-j

Go Up