Pages: [1]   Go Down
Author Topic: Understanding SPI  (Read 681 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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   >smiley-sad

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
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

PoA - RS - Brasil
Offline Offline
Newbie
*
Karma: 0
Posts: 27
-protect-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


0
Offline Offline
Faraday Member
**
Karma: 7
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: