Beagle Bone AI 64 fast pin toggle approx time 8ns .

I have a BeagleBone AI 64 board. I just want to toggle a gpio pin using internal register. i just run a demo code that was already available in my device. but toggle speed is very less approx 40ms. i want toggle the pin within few nanosecond. please suggest me how can i toggle gpio pin using internal register. or any other suggestion.

That is pretty good. You will not get any faster and most certainly will not get to nanosecond range. 1 nanosecond = 1 ghz. 40 millisec is 25 hz.

You would have to look at using the PRU and or some SoC with a dedicated PWM to go faster.

1 Like

You may want to check example pru_toggle. The PRU toggles a pin @20 MHz (50 ns), measured by a CAP input. The PRU code is slowed down by 4 no-op cycles, its max toggling frequency is 100 MHz (10 ns => too fast for the CAP module).


1 Like

Thank you! let me test once.

Thank you for you suggestion ! i will test in this way also.

1 Like

Hi, I just clone PRU cookbook into my beaglebone ai 64, there is some examples. But there is missing library files. I am unable to access it.
i used : / pru-cookbook-code · GitLab

Hello @DTJF and @foxsquirrel, i am new in beagle bone development. i dont know how to integrate and how to setup. I don’t know how can i getting start with beaglebone. I have BeagleBone black and Beaglebone AI-64. And i want to replace my another controller with this board because of speed. SO please guide me from scratch. Yes i know this is not a proper way to ask, So you can provide small task one by one.

Kundan jha

  1. My suggestion would be to use the BBB.
  2. Buy several books.

Most importantly get the BeagleBone Black book by Derick Malloy. He actually knows what is going on and is able to articulate the message to readers. Some stuff like the yocto builds is stale, however the rest of the book will be your best solution.

A few others exist too, if you are interested I can provide you with the titles too.

What you are trying to do touches too much, it is not practical to provide step by step on a forum.

ALL of us on here will most certainly help you out when you are at a hard spot in the process.

The remote processor has a clock speed of 200 MHz. That’s equivalent to 200000000 per second.

This time is equivalent to 5 nano seconds.

If we assume that a wave has a cycle of 10 nanoseconds, we can generate a square signal with a frequency of 100 MHz.

For examples, see this address.

Here, you can find the explanation of the same subject in different words. The examples have been tested.

However, the language is Turkish.

Realistically if you are doing the generating in a loop, the best you will get assuming you don’t want a 50% duty cycle if 66.66Mhz.
That’s assuming the jump/branch is also single cycle.

set pin high
set pin low
branch to start.

If you want 50% duty cycle you will need to include a nop, reducing the max clock to 50Mhz.

set pin high
set pin low
branch to start.

That’s assuming all you ever want to do is generate a square wave. If you want to so something useful besides just that, it will take more instructions slowing the max speed down further. How much will depend on what exactly you are doing.

What about hardware supported loops? Just check the example above

Up to 65535 times the PRUSS can toggle at 100 MHz!


OK, so thats what 655us of output @ 100MHz. Also forgetting that you can just XOR saving an instruction.

Still not going to achieve that if you are going to do something more than just toggle a pin. I guess it depends what you need to achieve.

It’s ~655 us when toggling twice in the loop, and ~6.55 ms when toggling 20 times in the loop, …

Sure, it depends on the aim.

where is this code from?