3

Hello I am i have connected an MCP23S17 spi GPIO expansion, upon testing it with the sample code from here, It does not seem to work. There could be many reasons why this is happening. I would like to narrow down the possible culprits. I would like to first know if my raspberry pi can detect the spi device. Is there an equivalent command for spi that detects if a device is present? Kind of like a ping request in networking.

Thanks

Jack
  • 686
  • 3
  • 7
  • 19

1 Answers1

3

There is no ping command. The best you can do is send a legal command and see a legal response.

I suggest you monitor the SPI bus (MOSI, MISO, SCLK, CS) and check that the correct data is being sent, and if so check that a response is received on MISO.

If you use a bus speed in the 100 kHz region you can use (my) piscope to visualise the bus.

Alternatively use monitor.py to get a console output.

joan
  • 71,014
  • 5
  • 73
  • 106
  • thank you for that suggestion sir, will look into it. – Jack Dec 29 '19 at 17:00
  • My current lead for me right now is that it would seem i pinned the chip select pin for an ordinary GPIO. Although that there is only 1 device in the spi line and i have set that GPIO to low, it would still not work. I am currently finding ways of using the chip select parameter of the library, but it is not well documented if it is possible to use an ordinary GPIO as chip select. I am not well versed with python do you think you can give the source code a look – Jack Dec 29 '19 at 17:11
  • That code only uses one of the standard chip selects CE0 or CE1 (see https://pinout.xyz/) depending on whether 0 or 1 is passed as the select parameter. – joan Dec 29 '19 at 17:20
  • i see so unfortunately is cant be changed aside from those two, but theoretically it should still work since the chip is still receiving a low chip select, SPI communications need the CS pin to be help low at all times during communications exchange right? – Jack Dec 29 '19 at 17:25
  • Yes, CS is normally high. When you want to talk to the chip you set its CS low, do the transfer, then set it back high. – joan Dec 29 '19 at 17:27
  • Oh did you create this software? Amazing sir. I do have some questions on how to make it work. I was able to make it run but how do i zoom in on the reading ? – Jack Dec 29 '19 at 17:45
  • Use the up and down cursor keys to change the time-line. – joan Dec 29 '19 at 17:47
  • Weird CE0 is being toggled what does that supposed to mean? is the library broken ? image – Jack Dec 29 '19 at 17:57
  • CE0 will be toggled by the SPI library and/or the kernel driver. See if you can slow the bus down to see all the signals. I can't see a clock. – joan Dec 29 '19 at 18:03
  • Oh wait it suddenly worked when i set the speed ! – Jack Dec 29 '19 at 18:20
  • I thought it suddenly work, but it would seem something just happened that made it output something random. but here is the image – Jack Dec 29 '19 at 18:26
  • It would seem the there is no data on MISO. I think i can rule out that the chip is faulty or damaged since somewhere along the trying to change the bus speed 7 out of 14 LEDS turned on(im using MCP to turn LEDS on/off). So far this is leading me to conclude that the library is faulty but it should be very unlikely – Jack Dec 29 '19 at 18:32