Setting pin mux settings in C code & reading from pins faster than using fopen, fread, fclose?

Hi everyone,
I’m working on a school project and am in way over my head. I need to control a lego NXT robotic arm using C code running on the BBB. I have the electronics part all sorted out - my groupmate is a wiz with that. The software is giving me trouble though - I’m used to using an old HCS12 board in the school labs, and the BBB is quite different…

I can export and read from the GPIO pins using the method shown here: https://learnbuildshare.wordpress.com/2013/05/29/beaglebone-black-digital-ouput/ . The file opening and closing for every read/write seems really clunky though when I’m trying to read quadrature encoder values… Would it actually work? Or do I need a better method? I think I read somewhere that the ports are memory-mapped and can be accessed that way - is that a different method? Can someone explain how I would do that in C?

Also, I need to set the pin mux setting in C as part of this program - can anyone point me in the right direction to do that? :slight_smile:

Thanks for reading and for any help you can give :slight_smile: I’m at the end of my rope with trying to figure this out with google… :confused:

Oh, not sure if this matters but I’m using VirtualBox with Debian, coding in Eclipse and cross-compiling onto the BBB which is also running Debian.

And just as a strange thing - I managed to get it to read an encoder value and it reads 0 as “48” and 1 as “49”… not sure what is up with that…

Hi!

I never used any cross compiler nor Eclipse. So I cannot help with that stuff.

I compile native on BBB under Debian and use Geany as editor (light IDE).

That way I wrote libpruio. An easy to use library that provides fast IO and run-time pinmuxing capability. Check it out, the package contains example code. (The current version doesn’t provide QEP yet. That feature is implemented in my working version, but up to now I couldn’t find the time to finish the upload.)

BR

You can use PRUs to read GPIOs and write in data memory of PRU if there is any change, link that memory location to a pointer in the C code that is running in main processor and you can directly read that memory whenever you want based on you frequency of changes. PRU coding can be done in assembly level as well as in C, there is C compiler for PRUs.