Go Down

Topic: SPI interface (Read 754 times) previous topic - next topic


As I understand it pin 10 is used as data latch (chip select). Now while using the SPI library in a sketch I want to use three other pins to a 238 to generate 8 data latches for 8 seperate devices having the data-in and data-clk chained together. 

1. do I have the concept of pin 10 use correctly
2. with the setup I would like to do  is it feasible with the software


SPI devices act like one or more 8-bit shift registers.  The SS signal going LOW latches the data and enables the shifting.  Each clock pulse (on SCK) moves one bit out of MOSI and one bit into MISO.  After 8 clocks, one byte has gone out and one byte has come in.

You can use 1-bit latches to implement 8-bit shift registers so, yes, you can use the SPI hardware to control your eight 1-bit devices.  The software shiftOut() function could be used instead but will be slower than the 8 Megabit rate of the SPI hardware.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


The way the Arduino's SPI works, it doesn't like working without D10 being used.

The best thing you can do is to use D10 as a master "enable" pin going to either G2A or G2B of the '238 (the other G2x linked to ground, and the G1 to Vcc).  Then, have your other three pins, say D7/D8/D9 to the A B and C pins.

All the outputs of the '238 will be low until you select the output to use with D7/D8/D9, and then send D10 low, which will send the output you selected high.

Now, that high is the opposite of what SPI devices expect - the chip select is (pretty much always) active low.  So, you will need to invert the outputs either using one-and-a-bit hex inverter chips ('04), or switch to using a '138 chip which has an inverted output (it also has only 1 inverted G input G2).


"The way the Arduino's SPI works, it doesn't like working without D10 being used."
Not only that, D10 Must be set as an OUTPUT.
Otherwise, the Arduino will act as an SPI slave.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up