These are some example programs to figure out how to program the PRU units in the Beagle Bone (Black/Green).
Forked from rvega/bbb-pru
The original code is no longer maintained and suggests this repo is more up-to-date and probably more useful. However, that one is also not actively maintainedi, the ADC inputs are sampled at 1500 samples per second and it includes things I don't need. I pulled in the library, though and intend to adapt it for my needs. Also pulled in the device-tree overlay.
The following packages need to be installed:
am335x-pru-package
ti-pru-cgt-installer
Look at the app-assembler example.
Look at the app-c example.
I have adjusted the adc example to fit my needs, namely to sample two channels as fast as possible. With the current code, I get a sampling rate of 1600 kS/s (or 800 kS/s per channel), the theoretical maximum in continous mode for two channels.
See: stack overflow
"The ADC subsystem in the AM335x CPU is clocked at 24 MHz and needs 15 cycles for a sample (14 in continous mode). This leads to a maximum sample rate of 1.6 (1.74) MSamples/s. See SRM, chapter 12 for details."
In addition to the clock cycles needed for the ad conversion, the sequencer which processes the programmable adc steps also has an "idle" step, which cannot be disabled. It appears this takes two clock cycles, which brings the total number of clock cycles needed for two channels at max speed to 30.
I added a calc_samplerate.py script to the apps/adc directory, in which I attempted to sort this out.
http://www.embeddedrelated.com/showarticle/586.php
http://www.embeddedrelated.com/showarticle/603.php
https://github.com/texane/pru_sdk
https://github.com/BeaglePilot/PRUSS-C
https://github.com/beagleboard/am335x_pru_package
https://github.com/VegetableAvenger/BBBIOlib
http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions
http://processors.wiki.ti.com/index.php/PRU_Assembly_Reference_Guide
AM335x SitaraTM Processors Technical Reference Manual
GPLv3