[sdiy] Why did this 100pF capacitor fix the SPI bus?

Richie Burnett rburnett at richieburnett.co.uk
Tue Feb 16 17:06:01 CET 2021


It's hard to know for sure without more info, but if the waveforms looked 
clean on a scope with no obvious reflections, then it's possible his code 
has configured the SPI peripheral to sample the SPI data line at the wrong 
time.  For example, if the data line changes state on the positive going 
edge of the clock, it should be sampled on the negative going clock edge 
where the data is being held stable.  Sometimes if you get this wrong it 
will work if one of the clock or data lines is longer, or there is more 
capacitive loading on one line.  But it can be right on the edge of working. 
Check the datasheet timing diagrams and the SPI peripheral configuration 
carefully.  There are 4 different SPI modes, (0,0) (0,1) (1,0) (1,1).  Make 
sure both ends of the link are set up for the same mode.

Another potential problem is coupling of the SPI clock signal onto one of 
the SPI data lines.  For example, if the data line changes state on the 
positive going edge of the clock, you would sample the data line on the 
negative going clock edge where the data line *should* be stable.  However, 
if the data and clock lines are long and run right next to each other, it is 
possible that the rapid falling edge of the clock line can induce a little 
negative going spike onto the data line right at the very moment when the 
receiving device is sampling it!  This can normally be taken care of by 
increasing the separation of the data and clock lines, or retrofitting 
resistors of a few ohms to tens of ohms in series with the data and clock 
lines at the driving end to limit the slew-rates.

-Richie,




-----Original Message----- 
From: Spiros Makris
Sent: Tuesday, February 16, 2021 3:36 PM
To: synth-diy mailing list
Subject: [sdiy] Why did this 100pF capacitor fix the SPI bus?


Hello list,
I was recently helping a friend debug his prototype, that uses the DAC8564, 
on the SPI bus of an atmega328p. I don't have the prototype here (and 
haven't seen in in real life), but through trial and error we managed to get 
it fixed.
The DAC is the only component on the SPI bus, and the exact same thing was 
working on the breadboard, with the exact same code. No matter what he tried 
and checked, the IC was just not responding to any commands at all. A 
picture of the waveforms captured with a scope didn't show anything 
suspicious either, like ringing, extreme overshoot etc. The length of each 
signal was <2cm for all signals of the SPI port.
Eventually he discovered that when jumper wires were connected to the 6pin 
SPI header, on the MOSI and GND lines, the damn thing magically worked. He 
didn't have to connect them to anything on the other side, mind you, just 
have them there.
I figured the only thing they could be changing electrically is acting as a 
capacitor, and eyeballed the value as 100p, based on the capacitance between 
two lines of the breadboard.
Well, what do you know, this actually worked. Now I am completely baffled as 
to why. Any ideas?





_______________________________________________
Synth-diy mailing list
Synth-diy at synth-diy.org
http://synth-diy.org/mailman/listinfo/synth-diy
Selling or trading? Use marketplace at synth-diy.org 


-- 
This email has been checked for viruses by AVG.
https://www.avg.com




More information about the Synth-diy mailing list