Computing stuff tied to the physical world

Too much capacitance is bad

The test code for the SPI flash erases sectors 0..9 (i.e. the first 40 KB), and then programs some values into the first 10 pages (i.e. bytes 0..2559). Each page gets three values: N * 11, N * 22, and N * 33 – some of these values will end up different due to 8-bit truncation.

This is what a good read-back of the first 11 pages should look like:

#0: 0,0,0 @ 491 ms
#1: 11,22,33 @ 493 ms
#2: 22,44,66 @ 495 ms
#3: 33,66,99 @ 496 ms
#4: 44,88,132 @ 498 ms
#5: 55,110,165 @ 501 ms
#6: 66,132,198 @ 503 ms
#7: 77,154,231 @ 505 ms
#8: 88,176,8 @ 507 ms
#9: 99,198,41 @ 509 ms
#10: 255,255,255 @ 511 ms

The last value on each line is the clock time since startup (SPI is not running at max speed). Also, the last line shown above comes from a page which has been erased but not written to, and as you can see, it’s all 0xFF’s, i.e. all “1” bits.

Unfortunately, the real test results are not consistent at all on the breadboard setup:

#0: 0,128,128 @ 608 ms
#1: 0,128,128 @ 610 ms
#2: 0,128,128 @ 612 ms
#3: 33,66,227 @ 614 ms
#4: 44,216,132 @ 616 ms
#5: 55,110,165 @ 618 ms
#6: 66,132,198 @ 621 ms
#7: 77,154,231 @ 623 ms
#8: 88,176,136 @ 625 ms
#9: 99,198,169 @ 627 ms
#10: 255,255,255 @ 629 ms

Keep in mind that this is serial data, and for some reason, MISO is receiving all 0’s, or a 1 followed by 0’s on those first three pages. So some signal levels seem to be wrong!

The problem must be either a voltage or a timing issue, since the chip is clearly working, i.e. receiving and returning data “more or less” as expected. The software too must be doing its thing – again, we’d never be able to erase / program / read back anything it it weren’t!

This is a typical hardware issue. In fact, it’s a fundamental electrical problem. Digital logic is all about 1’s and 0’s, and we’re not seeing the values we expect. At least not consistently.

An intermittent problem with voltage / timing (in reality, it’s both) points to an issue with “signal integrity”. What should be a clean pulse on the wire, isn’t. It can be quite tricky to analyse such problems – even just hooking up an oscilloscope probe might affect the signal.

But there’s one easy way to find out if we’re looking in the right direction: build the same circuit again with a substantially different electrical configuration and see how it compares:

DSC 5017

As you can see, this dataflash chip was soldered directly onto the back of an LPC812 board (from eBay). And sure enough: it works flawlessly, at full 12 MHz speed. Bingo!

So what’s going on here?

It turns out that the culprit is the combination of a high-speed dataflash chip and our solderless breadboard. From the Winbond W25Q64 datasheet:

Screen Shot 2015 04 15 at 15 08 20

The maximum specified load capacitance is only 30 pF: these SPI slave chips are meant to be placed very close to the SPI master, on a PCB with short and straight traces.

A solderless breadboard is a horrible way to connect high-speed signals (both analog and digital), due to the parasitic capacitance. Think about it: lots of little electrical connectors, all running in parallel and right next to each other – what a great way to create capacitors!

Add to that the fairly long jumper wires, their parasitic inductance, and you end up with a signal path that really messes up the leading and falling edges of these signals. These chips are intended to run at up to 100 MHz, i.e. with pulse edges within under 5 nanoseconds!

By having to charge / discharge capacitors along the way and by going through wires which act as little inductances, we’re really messing with the signal shape, introducing “ringing” and “overshoot” on all its edges. Unintended signal reflections will make it even worse.

Here’s another hint that these dataflash chips can only generate very weak signals:

Screen Shot 2015 04 15 at 15 17 43

The output voltage levels are specified at currents of only 100 µA. That’s not a lot to overcome any parasitic capacitance, which our setup must be adding to the circuit.

There are two conclusions to be drawn from all this:

  1. solderless breadboards are not suitable for every circuit, even simple ones
  2. we don’t always need high-end equipment to diagnose and fix such issues

Note that even with a 50..200 MHz oscilloscope it’s not always easy to figure this out. Such very high-speed signals will not render accurately, but worse still is that the probe itself is likely to affect these results: a standard scope probe adds 10..15 pF to the circuit! A high-end low-capacitance active FET probe would be needed, costing more than the scope itself.

But the good news is that we’ve identified the issue and found a first workaround.

[Back to article index]