Weird SPI communication problem - Page 1
Forum section: electronics / beginners

author: mheruian
author_rank: Contributor
timestamp: December 28, 2018, 04:48:26 am
content: Hello experienced folksI have a problem that i am really stuck into because i don't know why such unusual inconsistency in SPI transaction is happening on my setup. My current setup is that i have four (4) AD5160 spi digital potentiometers (setup as rheostat where A is not used and used these accordingly on the datasheet and same as on PMOD AD5160 module) and MCP23S17 spi i/o expander where the MOSI and SCK of these are connected to the arduino uno (MISO is not connected because transactions doesn't require feedback from the said spi devices) and the CS of each said spi devices were coming from a 16 channel DMX.Everything goes well as a do SPI transaction on digital potentiometers but the moment i wanted to add another spi i/o expander on the bus (even w/o the additional device connected to the bus yet) and do spi transaction on the digital potentiometers, the first two of these are receiving wrong data while the other two are not.The diagram below is my setup:and as you can see, the output of the 2 spi digital potentiometers have "x" marks meaning these devices output inconsistencies wherein meaning these 2 receive wrong/different data on what is being programmatically sent and this happens when SCK alone or SCK + MOSI lines are branched out connected to breadboard. The other 2 spi digital potentiometer are "checked" or good even such situation happens, no wrong/different data being sent.image below that spi transaction works (no wrong/different data being sent):image below that spi transaction doesn't works (wrong/different data being sent):it doesn't make sense right??same scenario happens even i try connecting those two lines to a different breadboard that has no connection to the circuit at all. I tried putting pull up and pull down resistors 10k but nothing happens, it didn't fixed the problem.. Why is that?

author: MasterT
author_rank: Frequent Contributor
timestamp: December 28, 2018, 11:25:53 am
content: Likely breadboard's capacitance is the cause. It's easy to verify by lowering SPI clock, arduino has:https://www.arduino.cc/en/Reference/SPISettings

author: AndyC_772
author_rank: Super Contributor
timestamp: December 28, 2018, 11:50:55 am
content: It's quite likely that your SCK signal has edges which are fast enough to cause issues with signal integrity on a breadboard. This has absolutely nothing to do with the clock speed (ie. number of clock cycles/second), and unless you have a high bandwidth scope (several hundreds of MHz at least), you won't see it.You can't cure this just by reducing the clock speed in software, but you might have some luck slowing down the edge rate. Try putting a 100R resistor in series with the SCK output from your microcontroller, as physically close to the microcontroller itself as possible. If that doesn't help, try 47R or 200R.[Advanced note: this isn't really 'slowing' at all, it's a series termination resistor which is there to absorb reflections coming back from the ends of your wires, and all the impedance discontinuities which inevitably exist on a breadboarded system. Try things like "series termination", "impedance matching" and "clock distribution tree" as search terms to learn more. You may wish to consider abandoning the use of breadboards for anything other than the most trivial of circuits, as issues like this are very common and largely a waste of your time trying to fix; you're better off spending the time designing a proper 4 layer PCB with a solid ground plane and a correctly structured, properly terminated clock tree).