Achievable toggle rate with GPIO (beaglebone)

Hi *,

I measured the toggle rate on one GPIO pin with a simple oscilloscope and a library I wrote to access the pin from user land (/sys filesystem). Toggling the pin achieves a frequency of about 3.9kHz. Writing the same program in bonescript with nodejs resulted in a toggle rate of about 1.9kHz. I think this is rather slow, or at least I was expecting different results.

I tried to research the problem a bit and only came across one link that said, that the GPIO pins have a different clock, but I think this was for the beagleboard. Could someone please shed some light on the board design and give me an idea about the toggle rate which would be reasonable?

Or to put the question in a more practical light. If I wanted to drive stepper motors via drivers and the Step/Dir/Enable interface the current rate would be much to low in my opinion. How would one start to design for such a problem using the beaglebone?

Markus

I'd use the PRU for the step signal, that should get a theoretical 66MHz. And virtually no jitter, since the PRU is a dedicated unit.

regards,

Koen

Thank you Koen,

and the GPIO unit? What is achievable there? Jitter or not jitter, 3.9kHz is still kind of boring :-)Researching for PRU did not yield any results in the beaglebone SRM - which domain does that belong to, where can I find out more? What does it stand for?

Markus

2012/3/21 Koen Kooi <koen@beagleboard.org>

Thank you Koen,

and the GPIO unit? What is achievable there? Jitter or not jitter, 3.9kHz is still kind of boring :slight_smile:

With a kernel driver you should get a lot better performance, not sure about the numbers.

Researching for PRU did not yield any results in the beaglebone SRM - which domain does that belong to, where can I find out more? What does it stand for?

Programmable Realtime Unit. Have a look at the AM335x manual or search the TI wiki for PRUSS.

regards,

Koen

Hi *,

[snip]

access the pin from user land (/sys filesystem)

It is not surprised that using /sys is rather slow since it caused
data transfer and context switch between user and kernel space. Better
solution would be to trigger GPIO with direct writes to the (mapped)
memory. It should be considerably faster but then the jitter might be
the problem. For this reasons I decide to test what could be
achievable with Xenomai (xenomai.org).

First, I try user-space xenomai application. Results were much better
then without xenomai but still not good enough under high system load
(jitter was to large and servo I was controlling starts shaking).
Currently I am working on the similar test application written also
with xenomai but running in the kernel space (xenomai RTDM driver). I
am expecting much better results but I am not ready yet. If you are
interested, you can take a look at the following article I've written
about it: veter-project.blogspot.com/2011/09/real-time-enough-about-pwms-and-shaky.html

Regards,
Andrey.

Thank you Andrey, that was interesting reading material. Have you actually tried using the “official” PWM pins instead of simulating with GPIO? Or solved your problem otherwise?

Markus

2012/3/21 Andrey Nechypurenko <andreynech@googlemail.com>

Yes, we are using available hardware PWM generators and they work just
fine (please note, that we are using BBxM and not Bone as you asked).
The source code could be seen here:
https://github.com/veter-team/vehicle . In particular,
https://github.com/veter-team/vehicle/blob/master/src/MotorControlI_PWM.cpp
shows how we control the tracked vehicle (two motors) with hardware
PWM generators.

The test described in the article was just to see what is achievable
with xenomai in user and kernel space. As I mentioned, I am not
finished the kernel-space implementation yet, but I am rather
optimistic with my expectations :slight_smile: .

Andrey.

Joheinz wrote:

Thank you Koen,

and the GPIO unit? What is achievable there? Jitter or not jitter, 3.9kHz is still kind of boring :slight_smile:
Researching for PRU did not yield any results in the beaglebone SRM - which domain does that belong to, where can I find
out more? What does it stand for?

there was a thread on the mailing list some time ago about GPIO speed:

http://groups.google.com/group/beagleboard/browse_thread/thread/e865d7cb1d691e86/245b67a87bc5abf3

Hi,

I recently did a pin toggle test on the Beagleboard (not -bone), directly accessing GPIO through mmap, and found that the time between two changes can be as short as 228ns, which means 4MHz.

Cheers, Günter (dl4mea)

On a beaglebone using mmap with 5v power (720MHz) I got 2.48Mhz toggle speed (2.13 MHz for USB power 500 MHz).
snippet of code to toggle USR1 USR2 and USR3 LEDs looks like

#define GPIO1_START 0x4804C000

int gpio_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (gpio_fd < 0) {
printf(“Could not open GPIO memory fd\n”);
return 0;
}

// GPIO configuration
printf (“map GPIO\n”);
volatile ulong gpio;
gpio = (ulong
) mmap(NULL, 0xFFF, PROT_READ | PROT_WRITE,
MAP_SHARED, gpio_fd, GPIO1_START);
if (gpio == MAP_FAILED) {
printf (“GPIO Mapping failed\n”);
close(gpio_fd);
return 0;
}
for (j=0; j<1000000; j++)
{
gpio[0x194/4]=0x00e00000; // set
gpio[0x190/4]=0x00e00000; // clear
}