After I had written the mandatory "Hello World" program in C, and running it on the BeagleBone Black, I decided to play around with some GPIO ports to see if they were capable of doing what I wanted to do. I wanted to be capableable of switching several ports (8 total) at around a 250 KHz rate, so that I could create a parallel interface for a device that I was planning. After reading up on GPIO programming in C on the BeagleBone, it began to look like what I needed to do was not possible while running the Linux operating system. One of the problems was that the suggested method to operate the GPIO ports in Linux is by writing to the ports using a file system to open a file for each pin, and then fprinting a 1 value to one location to set the port high, closing the file, then fprinting a 1 to another location to set the port low (clear) and then closing that file, seemed to be VERY SLOW. I started out using a single GPIO pin and setting it high and low in an infinite loop to see just how fast this could be done using the suggested method in the Linux kernel.
I was very disappointed to find that the fastest I was able to switch with this method was around 8 KHz. (very much slower than the 250 KHz. target I wanted). Also the timing would be the same for a few cycles, then have a longer cycle and then the same again (I assumed that the Linux kernel was doing something during this time and delayed the GPIO switching for a period). Next, since I needed to be able to switch 8 pins at the same time, I wanted to know how much delay would be involved between the writing of one pin and the next (the maximum I would be able to tolerate with my intended plans would be on the order of 1 microsecond or less). I re-wrote the program so that I would write 1 GPIO pin high, immediately followed by writing another GPIO pin high, then immediately writing the first pin low, followed by writing the Second pin low in an infinite loop.
The results disappointed me even more. By just increasing from using 1 pin to two, the frequency decreased from around 8 KHz. to around 4 KHz. Extrapolating that to eight pins would lead to a frequency of probably less than 50 Hz. total (WAY TOO SLOW). The other thing that was unacceptable was the delay between writing to each pin. You can see from the logic analyzer picture below that the difference between the time the first GPIO is set high (marker T1) and the time the second GPIO is set high (marker T2) is 62.375 microseconds. This value WAY exceeded my tolerance of around 1 microsecond. From these tests I have concluded that I am not going to be able to use Linux to do what I need to do. There is a register on the ARM processor that lets you write highs and lows to GPIO pins all at the same time, but I was not able to find a way to do this using Linux. SO... I have decided to use my own program to access the hardware in the ARM processor directly. That means writing a lot of C code and probably also writing some libraries. I am currently awaiting the arrival of some Samtec connectors so that I can install a JTAG connector on my BeagleBone. After that I will be able to load and debug C code directly on the BeagleBone without booting the Linux Kernel. That's all for now.