Jump to content
LIJsselstein

Decoupling cap: small but beautiful (and necessary)

Recommended Posts

So today I breadboarded an Adesto AT45Dxxxx DataFlash chip with an G2553 (TSSOP28 on a breadboard adapter) and wrote a quick test sketch in Energia using software SPI. The sketch queried the Manufacturer/Device id every second and communication was very spotty with a correct result in only about a fifth of the queries. At first I thought is was a software error so tried various things like adding delay(1-10) after pulling the CS low and stuff like that. Generally it got worse, at least not better. This got me quite confused for an hour or so but during lunch the penny dropped: what if I added some decoupling caps? Sure enough, the datasheet had some hints:

 

 

The serial interface is controlled by the Serial Clock (SCK), Serial Input (SI), and Chip Select (CS) pins. These signals must rise and fall monotonically and be free from noise. Excessive noise or ringing on these pins can be misinterpreted as multiple edges and cause improper operation of the device. PCB traces must be kept to a minimum distance or appropriately terminated to ensure proper operation. If necessary, decoupling capacitors can be added on these pins to provide filtering against noise glitches.

 

 
 
Adding 100nF between Vcc and GND pins immediately improved communication a lot (really should have added that one from the start). Adding another cap on the SO-pin resulted in perfect communication, interestingly SO is not mentioned in this context but this may be coincidence in my case. Also adding a 100nF to the SCK or CS line as suggested by the datasheet made communication much worse in my case, perhaps 100nF is a bit too much?
 
Anyway, I learned my lesson (again): decoupling caps are small but beautiful (and necessary). Especially when breadboarding! :)

Share this post


Link to post
Share on other sites

Thanks spirilis! This topic should actually be renamed to 'series resistor' instead of 'decoupling capacitor'. Your comment triggered some long forgotten training and Googling around gave some helpful pointers to refresh thing a little e.g. http://electronics.stackexchange.com/questions/33372/spi-bus-termination-considerations

 

So what I really need to do is get an oscilloscope and add some termination resistors near each driving pin, in the 50 Ohm range you suggested. If that does't improve things enough than an decoupling capacitor might help.

Share this post


Link to post
Share on other sites

Thanks spirilis! This topic should actually be renamed to 'series resistor' instead of 'decoupling capacitor'. Your comment triggered some long forgotten training and Googling around gave some helpful pointers to refresh thing a little e.g. http://electronics.stackexchange.com/questions/33372/spi-bus-termination-considerations

 

So what I really need to do is get an oscilloscope and add some termination resistors near each driving pin, in the 50 Ohm range you suggested. If that does't improve things enough than an decoupling capacitor might help.

50 ohms is a number I pulled out of the air FYI... But it probably won't hurt.  I'm sure there is an "optimum" value for minimizing ringing and that's the sort of optimization work "real" engineers have to do to discover e.g. why 27R/47pF are ideal for USB 2.0 Full Speed :-)

Share this post


Link to post
Share on other sites

It doesn't sound right to me calling capacitors on signal lines "decoupling capacitors" sounds more like you've created an RC filter. With the R being the gate resistance of the driver behind the IO pin.

 

What you're actually seeing is the effects of transmission line theory! Basically when a digital signal changes state very quickly (slew rate, or edge rate) it creates harmonics. On modern chips, even slow (by clock rate) micro controllers, that can span into the 100MHz range. This basically oscillates in your PCB tracks due to their inductance causing ringing on the edges due to reflections from impedance mismatch. If this ringing is bad enough then you will get data corruption.

 

Adding a series resistor helps, because if you picture your PCB tracks or wires as transmission lines then the resistor acts to impedance match between the IC pins and your PCB tracks. a 50 ohm resistor is ideal for a 50 ohm transmission line.

 

Here is a quick primer that very concisely explains the basics of this stuff if you don't have a strong EE background.

Share this post


Link to post
Share on other sites

Thanks Greeeg, and you're right I don't have an EE background, it's primary in process control and automation. Interesting video, glad my chips didn't blow up in my feeble attempts :)

 

Removing the caps (except between Vcc and GND on the Dataflash chip) and adding 47 Ohm series resistors on the data/clock lines as close to the transmitter as the breadboard permits seems to work.

Share this post


Link to post
Share on other sites

Thanks Greeeg, and you're right I don't have an EE background, it's primary in process control and automation. Interesting video, glad my chips didn't blow up in my feeble attempts :)

 

Removing the caps (except between Vcc and GND on the Dataflash chip) and adding 47 Ohm series resistors on the data/clock lines as close to the transmitter as the breadboard permits seems to work.

 

haha, I'm sure that ICs have become more resilient over the years.

 

Glad to hear it's working for you. I mean if the caps were working, by all means you could leave them in. However it's probably not the best practice, ever transition essentially needs to charge or discharge all the energy in those capacitors if they're on the signal lines. This could become a significant power drain if running from batteries.

 

But yes, decoupling capacitors (across power rails) are a very good thing.

Share this post


Link to post
Share on other sites

Thanks again for helping me along! :)

 

Things are currently still in breadboard stadium so line impedance will certainly change once the circuit gets translated into PCB. I'll add series resistors by default and tune them to match the board, keeping in mind that a cap might be useful if the resistors turn out not working well enough. I intend to have the SPI bus fan out to one or two separate boards later and read in the StackExchange link above that a cap near the middle of the wire (say near the connector of the MCU board) can help in that case. The whole setup is supposed to be low power and running on batteries, however there is occasionally a pretty large power consumer so in respect to that a few well spent uA's more for stable communication don't matter that much.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...