1

I have enabled SPI on my Raspberry Pi 3, and want to know why the mode for physical pins 24 and 26 are set to Mode 'OUT' and not 'ALT0'. According to the documentation here and here the mode of all of these pins should be 'ALT0'. So what is the deal?

Here is a screen shot when I execute gpio readall from the commandline.

gpio readall output

If I execute the command gpio mode 10 alt0 it does change the mode of physical pin 24 to 'ALT0', but when I reboot, or cycle power (after a graceful shut down), the mode changes back to 'OUT'.

1
  • SPI's chip select pins are basically output pins that select which slave has to be active by pulling them low. So I guess that really wouldn't matter.
    – MaNyYaCk
    Jul 18, 2018 at 5:14

1 Answer 1

2

It depends on whether the SPI software driver you are using is setting the slave selects (CE0/CE1) itself or if it is letting the SPI hardware set the slave selects.

If the SPI hardware is setting the selects those GPIO need to be in mode ALT0. If the SPI software driver is setting the selects those GPIO need to be in mode OUTPUT.

The original Pi SPI software driver let the SPI hardware set the selects (so they were ALT0).

The current Pi SPI software driver sets the selects itself (so they are OUTPUT). The principal reason is so that the current driver can support more slave selects than the hardware.

4
  • Thanks. What I just noticed is that after I have uninstalled (purged) wiringPi from my system, the example software "~/Adafruit_Python_MCP3008$ python simpletest.py" works consistently, even after a reboot. My assumption is that there is software contention between software drivers when wiringPi is installed. How do I determined what other software drivers are running in the background? Ultimately I need wiringPi installed as pi4j is dependent upon it.
    – mike
    Jul 18, 2018 at 15:47
  • @mike I have never heard of such a contention and can't think of any mechanism which would allow such a conflict. Coincidence?
    – joan
    Jul 18, 2018 at 16:35
  • I am doing a clean install on another pi 3 and see what happens.
    – mike
    Jul 18, 2018 at 18:14
  • After several attempts I got a clean install (many segmentation faults occurred when installing Ubuntu Mate...but thats another issue) and I got SPI working.
    – mike
    Jul 20, 2018 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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