Change GPIO Drive Strength

Hey guys,

I was wondering if it was possible to set/change the drive strength of the GPIO pins on the Particle P1? I know that it is possible with the Raspberry Pi by programming the pin’s output current (reference: http://raspberrypi.stackexchange.com/questions/1130/what-is-the-nominal-gpio-pin-output-current/1154#1154)

The reason I want to do this is to reduce the amount of noise on the output of my SPI line. I need my SPI clock speed to be set at 10MHz, however when I probe the data line it is quite noisy (scope capture below). The two alternatives I am currently considering to reduce the noise is to use an external RC filter, or reduce the drive strength of the GPIO.

Thanks!

@m23rashid, the noise you see can be caused by improper calibration of your scope probes, not using 10x on the probes to increase their impedance or connecting wires being too long. Are you seeing an “effect” on your GPIO that needs fixing? Are you looking to a fast rise time? What is your requirement exactly?

1 Like

@peekay123 I was hoping to reduce the overshoot/ripples by slowing the rise time. The connecting wire are indeed pretty long, I will try using a shorter wires next.
However, I also tried using a Beagle I2C/SPI Protocol Analyzer to check the MOSI line. To do the testing, I tried transferring “0xAA” with a clock speed of 1MHz and 10MHz. So for the 1MHz I saw 0xAA on MOSI on the Beagle Analyzer as expected, but for 10Mhz instead of “0xAA” I get “0x40” or “0x80” instead. So that led me to think that there might be a signal integrity issue.

@m23rashid, you may be able to change the GPIO drive but not without affecting other pins on the same port group. SPI lines should be kept short for that very reason. You can also add a set of line drivers to increase the drive output. What sampling rate is your Beagle analyzer set for? I would use a "real" SPI device to see if the problem is real or simply a sampling issue. At 10MHz, your analyzer needs to sample at least at 20MHz but more realistically at 4x or more. From the Beagle specs:

† Actual SPI capture performance is dependent on CPU speed and SPI bus throughput. 24 MHz SPI capture has been tested for typical applications (e.g., captures of a few hundred SPI packets). Depending on user configuration, the maximum achievable capture throughput for continuous streaming applications may be less than 24 MHz.

What SPI device are you driving and what are your wire lengths?

1 Like

@peekay123, You’re right, I wasn’t sampling at a high enough frequency. The sampling frequency on the Beagle was set to 10MHz. After changing it to 20MHz, I’m no longer having the issue.
With regards to the noise seen from the probe measurements, the length of the wires I am using for probing are approx. 200cm. So this might be causing the extra noise.
Thanks for your help, appreciate it!

@m23rashid, glad to help! Are you saying you are using 200cm wires to connect to an SPI device???

@peekay123, oh no, the connection to the SPI is done with traces on the PCB which are fairly small. But to probe the MOSI line I was using wires that are 200cm long.

1 Like

@m23rashid, the 200cm (2m!!) probing line WOULD cause the ringing if they are not shielded for sure. Even with shielding, the intrinsic capacitance and inductance of those lines will cause havoc on high rise-time signals. :smiley:

1 Like

@peekay123, Oh sorry! My bad, I mean 200mm wires, which are still very long lines.

@m23rashid, LOL!!! You are right, 20cm is still very long and the same rules apply. Also, as you found out, understanding the test equipment and conditions can vastly affect what you “think” the results are seeing are correct. This is a great topic for other members! :wink:

2 Likes

@peekay123 haha you’re right, definitely a god lesson learned. Thanks again!

1 Like