SPI Clock problem - self-heal when scoping it

Thread Starter

james101

Joined Jan 12, 2010
17
Hello all,

I have 2 MCUs talking to each other using SPI @ 5Mhz and I get data error very often (about 50% of the time). When I connect the scope to look at the SPI Clock, the error suddenly goes away.

I found that even when I disconnect the probe from the scope and the ground clip from the board (only the tip of the probe is connected to the SPI Clock), the error can also be eliminated. I tried putting a 10pF cap from the Clock signal to ground, but the problem is still there.

There is no spikes on the SPI Clock. The probe is Tektronix P6138A and its spec can be found here
http://www.testmart.com/sp.cfm/PROBES/TEK/P6138A.html

What's my problem?
James
 

SgtWookie

Joined Jul 17, 2007
22,230
Try looking at the signal by getting your scope probe near the trace, but not touching it. Increase your channel V/div until you can see the signal. I have a feeling that you'll see a good bit of inductive ringing after level transitions.

Show your schematic and your board layout.
 

Thread Starter

james101

Joined Jan 12, 2010
17
The SPI Clk trace is highlighted in yellow in the picture below. The ground layer is turned off.

The main dsPIC33FJ256GP710 with its SPI connecting to:
- DAC8534
- 25LC1024 EEPROM
- FM25L512 FRAM
- AT45DB642D DataFlash
- ENC28J60 Phy
- PIC18F2620

There are about 9 pages of the schematic and I don't think I can post it.
James
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Well, I don't have much of an idea of the scale of the board, but looks like that trace winds around for several inches at least. It'll have a fair amount of inductance, and who knows what kind of capacitive coupling you have; it could be calculated out.

You're putting some fast rising/falling edge signals on the SPI trace. You might try slowing down those edges a bit by using some small SMT resistors in the trace at the origination/termination points; maybe even 5 Ohms would be enough.
 

GetDeviceInfo

Joined Jun 7, 2009
2,192
Another thing you might consider is to closely inspect the board for flux residue. Try scoping a parallel running data line (spi) to see if the problem corrects, or you can see the suggested ringing. Many times such a problem affecting one line of a device will propogate thru to it's other pins.
 

Thread Starter

james101

Joined Jan 12, 2010
17
When I move the probe closer to the CLK line, I can see the clock signal (150 mVpp) along with some noise spike. What am I really looking for?
James
 

kubeek

Joined Sep 20, 2005
5,794
When I move the probe closer to the CLK line, I can see the clock signal (150 mVpp) along with some noise spike. What am I really looking for?
James
Something like this? This is my very rough guess on the trace parameters, but I think it should be in the ballpark. As was SgtWookie saying, this is caused by the inductance and capacitance of the trace, which creates a series resonant circuit. And if the dip after the first high peak crosses the threshold of the input, it creates a double clock impulse to the SPI circuit.
 

Attachments

Thread Starter

james101

Joined Jan 12, 2010
17
Yes, that's what I saw. So, adding a series resistor (5ohms or so) at the clock output (at the SPI Master MCU pin) will reduce the spike? Do I need to add a small capacitor to "low pass" it?
James
 

kubeek

Joined Sep 20, 2005
5,794
Yes, some resistor in place of R1 should reduce it. It is just hard to guess the right value. You might need to try a few I think, but it should be somewhere between 20-100ohms. Try 47 for a start and see if the risetime isn´t too long.
 

SgtWookie

Joined Jul 17, 2007
22,230
Great news! Looks like I was off by an order of magnitude :rolleyes: ;)

Now that you know 47 Ohms works, you might try reducing and increasing it to see what is the optimal value to use. If it's too large, your rise/fall times will suffer, and you might start getting errors. Too small, and you're back to the ringing.
 
Top