netduino GPIO speed test
I wanted to figure out the kind of throughput achievable through bit-banging on GPIO pins on the netduino.
The basic idea for the test was to flip a bit as fast as possible on a single output pin connected to an LED with a ~215 ohm resistor, measuring the frequency of the changes on an oscilloscope.
The little code snippet below is about as simple as it gets for this test.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace GPIOSpeedTest
{
public class Program
{
public static void Main()
{
var d0 = new OutputPort(Pins.GPIO_PIN_D0, false);
while (true)
{
d0.Write(true);
d0.Write(false);
}
}
}
}
The result turned out to be surprisingly low, clocking in @ 8.4 kHz!
8.4 kHz = 8400 bits / sec = 1050 bytes / sec.
To put things into perspective, according to the list of device bit rates on Wikipedia, 8.4 kHz lands us right around modem technology circa 1989.
Ah! To feel young again
Fortunately, extremely fast serial protocols, such SPI and I2C, are built into the ARM 7 hardware powering the netduino and are easily accessible from the .Net Micro Framework.
Cheers,
-Fabien.


.
.
.
Ouch … that is pretty slow, but I suspect it’s the way they’ve implemented the GPIO in the port to their HW rather than something specific to the NETMF (though it’s been a while since I’ve worked with it as well). I would have expected something faster even with the different layers you have to go through to get to the specific GPIO data register. It might be worth bringing this up with the Netduino people since there’s obviously a lot of room for improvement here.
Hi Kevin,
Yes, I agree. I also expected a faster response time.
There are multiple ways to solve this issue and it was brought it up to the netduino folks in a few threads, this one for instance
: http://forums.netduino.com/index.php?/topic/1155-quick-and-dirty-gpio-speed-test-findings/
I’m sure that a future netduino firmware revision will address it.
Cheers,
-Fabien.