GPIO speed (MHz)
#1
Posted 25 February 2011 - 10:22 AM
What is the normal and max toggle (On/Off) speed of GPIO of netduino?
Thanks
#2
Posted 25 February 2011 - 10:59 AM
#3
Posted 25 February 2011 - 11:18 AM
I just read your previous posts as well where you were able to get GPIO speed upto 6MHz with netduino.
But my question is even after accessing the PORTs directly what could be the maximum speed is possible for toggling GPIOs?
For example, I'm able to get max 8MHz by direct PORT addressing in Arduino running at 16Mhz.
It takes only 62.5nS to execute one instruction.
While netduino is running 48MHz ARM7 my expectations are high!!
Please advice
Regards
If you want to toggle GPIOs rapidly, you're looking at something along the lines of:
C# code:
A few milliseconds
C++ code:
~1 microsecond
You can mix the two if you'd like (do your GPIO activations in native code, and your logic in C#). And since Netduino is 100% open source, you get access to the rich internals of .NET MF in your native code--not just a subset.
Then again, if you want to toggle a GPIO on and off as fast as possible...there's hardware PWM.
Welcome to the Netduino community,
Chris
Attached Files
#4
Posted 25 February 2011 - 11:32 AM
While netduino is running 48MHz ARM7 my expectations are high!!
48MHz is 3x faster than 16MHz. GPIO ports may run a bit slower than native MCU instructions...but they will still probably be faster at 48MHz than 16MHz when using native C code accessing memory registers.
If you have a Netduino and a copy of GCC, grab Atmel's SAM7X-EK software examples and put together a quick test using their GPIO "set output" code. You should be able to measure the speed on your oscilloscope (or logic analyzer if it has a high enough resolution).
Chris
#5
Posted 25 February 2011 - 11:59 AM
I know what do you mean.
I don't have a netduino but I wanted to get one.
So want to know its performance before I buy one.
Basically I want to drive 64 pixels of RGB LEDs with 8-bit greyscale and 30 frames/sec and I need to decide between AVR32 UC3 and ARM SAM7.
Appreciate your help
Regards
48MHz is 3x faster than 16MHz. GPIO ports may run a bit slower than native MCU instructions...but they will still probably be faster at 48MHz than 16MHz when using native C code accessing memory registers.
If you have a Netduino and a copy of GCC, grab Atmel's SAM7X-EK software examples and put together a quick test using their GPIO "set output" code. You should be able to measure the speed on your oscilloscope (or logic analyzer if it has a high enough resolution).
Chris
- cric likes this
#6
Posted 25 February 2011 - 12:48 PM
You're looking at a maximum of around 60-70ns for a full rise-and-fall of a pulse using native code on the Netduino's AT91SAM7X microcontroller. I built a test using FIQ timer-based interrupts, generating a high-low pulse every 1 microsecond. You can see the full details here and the screenshot of the 1us FIQ (with <=70ns pulse) below.
I have updated my conservative number in the first response above to reflect this (<=70ns vs 1000ns).
Chris
Attached Files
#7
Posted 25 February 2011 - 12:50 PM
#8
Posted 25 February 2011 - 01:04 PM
So it takes approx 1 microSec to go back into loop and 82 nSec to execute 1 GPIO instruction.
Thats great stuff!
Thanks a lottt, you made my day!!
P.S. its time to upgrade your Saleae to ver 1.1.4 ;-)
Dirty Bits,
You're looking at a maximum of around 60-70ns for a full rise-and-fall of a pulse using native code on the Netduino's AT91SAM7X microcontroller. I built a test using FIQ timer-based interrupts, generating a high-low pulse every 1 microsecond. You can see the full details here and the screenshot of the 1us FIQ (with <=70ns pulse) below.
I have updated my conservative number in the first response above to reflect this (<=70ns vs 1000ns).
Chris
#9
Posted 25 February 2011 - 01:04 PM
Basically I want to drive 64 pixels of RGB LEDs with 8-bit greyscale and 30 frames/sec and I need to decide between AVR32 UC3 and ARM SAM7.
To echo what Mark H said, if you're looking to decide between AVR32 UC3 and ARM SAM7 for native code programming, you may want to look at ARM SAM3 instead. They don't have anywhere near the flash and RAM of the SAM7 used on the Netduino, but they're faster than either of those two options since they're Cortex M3.
Then again, we always love new community members who like programming Netduinos in C/C++. We can't provide a lot of support for non-.NET programming, but Netduino is made for hacking.
Chris
#10
Posted 25 February 2011 - 01:07 PM
So it takes approx 1 microSec to go back into loop and 82 nSec to execute 1 GPIO instruction.
Thats great stuff!
Actually, it takes much less than 1 microsecond to loop. It takes less than 100ns to loop. The 1 microsecond period you were seeing there was the time it took to activate an FIQ interrupt based on a timer, call the interrupt method, toggle a pin on and off, exit the interrupt, wait a while, and then start over
#11
Posted 25 February 2011 - 01:09 PM
#12
Posted 25 February 2011 - 01:13 PM
#13
Posted 25 February 2011 - 01:16 PM
Woww..
I gotta get netduino then..
Actually, it takes much less than 1 microsecond to loop. It takes less than 100ns to loop. The 1 microsecond period you were seeing there was the time it took to activate an FIQ interrupt based on a timer, call the interrupt method, toggle a pin on and off, exit the interrupt, wait a while, and then start over
#14
Posted 25 February 2011 - 01:36 PM
Just remember...if you want to toggle pins on and off really quickly, you'll need to do it in native C++ code. Which means that you'll either wipe .NET MF off the device and write code from scratch, or you'll need to get comfortable compiling the Netduino firmware with GCC...and adding native code using .NET MF interop.Really
Woww..
I gotta get netduino then..
I'm looking forward to seeing what you build!
Chris
#15
Posted 25 February 2011 - 01:49 PM
Just remember...if you want to toggle pins on and off really quickly, you'll need to do it in native C++ code. Which means that you'll either wipe .NET MF off the device and write code from scratch, or you'll need to get comfortable compiling the Netduino firmware with GCC...and adding native code using .NET MF interop.
I'm looking forward to seeing what you build!
Chris
#16
Posted 26 February 2011 - 05:11 PM
After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.For example, I'm able to get max 8MHz by direct PORT addressing in Arduino running at 16Mhz.
If you are interested, my writeup is here
#17
Posted 27 February 2011 - 07:29 PM
Well I did tried that (serial data transfer - SPI) with Arduino few months ago (that time I wasn't that good with using Arduino) and get data transfer speed > 2MHz (Mega bits/Sec). I haven't tested it further because I needed only 1.4MHz. However this data was achieved by...
1.Using Arduino's standard SPI library without any tweaking
2.Arduino was running at 16MHz
3.I have used Matlab's SPI function to send Data from PC to Arduino and not the standard Serial Monitor.
If you just want simple arbitrary serial data transfer (not SPI) on a single out-put pin on Arduino than you can get > 4MHz (Megabits/Sec provided Arduino's running at 16MHz clock).
In a nutshell we need to find a way to use the processor to the max!!
Same goes with Netduino. And I want to know more ways to use Netduino to the maxx!
After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.
If you are interested, my writeup is here
#18
Posted 27 February 2011 - 09:32 PM
After reading your post I got interested in this question and tried to figure out how fast I could make the Netduino go for serial communication. It turns out I am able to move arbitrary serial data at a rate of 4.3 megabits. I would love to see if the Arduino can do better on this benchmark.
If you are interested, my writeup is here
I just read your write-up..Interesting work..well done for that!
I don't have Netduino at the moment so I can't try to improve that however I will try with Arduino and will post the result. Hopefully it shouldn't outperform Netduino else I will be in trouble because I'm planning to use ARM MCUs instead AVRs in my next project.
Stay tuned!
#19
Posted 06 October 2011 - 03:59 AM
If you want to toggle GPIOs rapidly, you're looking at something along the lines of:
C# code:
A few milliseconds
C++ code:
~60-70 nanoseconds or less (<=0.7us) <-- updated from previous conservative estimate of ~1000ns
You can mix the two if you'd like (do your GPIO activations in native code, and your logic in C#). And since Netduino is 100% open source, you get access to the rich internals of .NET MF in your native code--not just a subset.
Then again, if you want to toggle a GPIO on and off as fast as possible...there's hardware PWM.
Welcome to the Netduino community,
Chris
Chris,
I was wondering if there are some step by step instructions to say have some type of "Native Code" mixed in with a typical Netduino project...
What I am looking to do is have an function run every 20u seconds (like a timer). In this function I would like to do things like to check the status of some variables and potentially write out a high/low to a port. I don't think using the standard C# i could do it that fast but I haven't tested it yet. Are there any code examples on how to do something like this?
Thanks,
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users