Wednesday, November 21, 2012

Note about SPI chips behaving in a weird way

In my recent electronics projects, I encountered two cases where a chip supporting the SPI protocol behaved in a weird or inconsistent way when communicating with the computer controlling it. I had an ADS 8320 Analog-Digital-converter (which should measure some voltage 100k times per second in 16bit resolution), which reported data like this when given a monotoneously rising, then falling voltage:
Weird data received from an AD converter via SPI (axes are x: t/samples, y: voltage/LSB)
And recently, I had an ADF 4350 (a RF frequency synthesizer), which randomly sometimes reacted to my commands sent via SPI, and sometimes did not.

The problem turned out to be the same in both cases: the cable from the SPI controller to the chip was too long, apparently, and the signal got corrupted a bit -- not much, but obviously enough for it to stop working (altough the signal looked perfectly clean on an oscilloscope!). Soldering 100pF condensators from the SPI lines to GND close to the chip instantly made both chips work reliably; the data from the ADC is nice and clean, and the ADF 4350 executes all commands as it should.
Same test as above, but with 100pF condensators on the SPI lines :)
So, if you're using SPI with a controller which is not very close to your chip (like, when using the raspberry pi and a breadboard), make sure to add some noise reduction circuitry!

5 comments:

  1. Hi, i` have raspi and adf4350 can you give me your testing codes..

    ReplyDelete
    Replies
    1. Here's a script which generates the registers:
      http://files.svenbrauch.de/adf4350.py
      Don't forget to adjust the input frequency. You need to add code to send that out via SPI yourself.

      Delete
    2. One question: 3.3 <---> 5 converter need?

      Delete
    3. If your SPI master uses 5V, then yes, obviously, because the ADF4350 uses 3.3V

      Delete

Note: Only a member of this blog may post a comment.