0
\$\begingroup\$

I have a BeagleBone white and I want to use it as a master which is connected to 2 slaves via an SPI connection, besides SCLK, DIN, and DOUT there is one pin of chip select "CS" "just one" and I need 2 because I have 2 slaves, what I already knew is that I can use any GPIO pin as chip select, but when I saw the "CS" pin I get confused, can I use any GPIO pin as a chip select ? if yes, why there is a pin with the name of chip select ?

\$\endgroup\$
1
\$\begingroup\$

Yes, you can use any digital out as a CS. Use some other pin for a second chip select, and bit bang it. Bit banging will never get any easier than that.

Alternatively, you might consider just NOT-ing the one chip select, and seeing if you can get away with controlling two slaves that way.

\$\endgroup\$
  • 1
    \$\begingroup\$ . . . and a third alternative, if your application and your slave devices allow it, is to daisy-chain them and access them together with the one chip select. \$\endgroup\$ – Mark Jul 19 '16 at 20:02
1
\$\begingroup\$

I assume you use SPI0. Another option is to use SPI1 instead which has both CS0 and CS1 available on the expansion headers.

(At least in theory. I'm currently trying to achieve the same thing, but I've failed to enable both CS0 and CS1 for the pins connected to the expansion header using TI's pinmux tool. There seems to be no available IO-set that includes all the required pins. Any hints appreciated...)

\$\endgroup\$
0
\$\begingroup\$

With micros you have a dedicated spi "block" if it includes a CS, it may be able to assert the CS line automatically and there is usually a designated pin. Most SPI hardware blocks do this is so when preforming writes you don't have to spend precious CPU cycles to assert a gpio pin if you need fast timing. You don't have to use the SPI block's CS lines, you can use any GPIO line, however you have to write code to turn it on and off.

As long as fanout works out for you GPIO (which shouldn't be a problem for two devices) and the devices have the same logic level you should be fine.

But why would you want to? You have plenty of pins so you could have two different GPIO's and control them seperately or at nearly the same time. The only application I can think of is simultaneous sampling with an ADC to make sure you start at the same instant. If you bit bang the SPI port you can even have two seperate SDO's so you trigger the CS line to start the conversion at the same time, and write the same value into both ADC's and then read back both values simultaneously on two different GPIO's connected to two different SDO's of the slave devices. If you roll your own spi code you have more options.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.