PRUSS and accessing ADC registers on Beaglebone Black

Hi everyone,

I have been trying to use PRU to read multiple ADC inputs. Unfornately, I am stuck at accessing to the ADC registers (chapter 12 on AM335x technical reference manual). I set the OCP registers, checked the PMAO registers on PRU to ensure access to external host. For example, I read the ADC REVISION as below: (tried to write to STEPCONFIG and STEPENABLE, etc.)

MOV r13, 0x44E0D000 //ADC REVISION
LBBO r5, r13, 0, 4
SBCO r5, C28, 4, 4 //store REVISION to shared memory to show with C program

… but everything returns 0.

I install Ubuntu 13.04 on Beaglebone Black, tried kernels 3.8, 3.12. PRU worked with shared memory accessing, and GPIO1 registers (I am not sure what to try next) . I haven’t tried it on the official Angstrom image, because I still couldn’t get PRU to work right away on it.

On this link: http://beaglebone.cameon.net/home/reading-the-analog-inputs-adc . There are some comments saying that it works.

Please let me know if you need anymore details.

Or if someone has it working, please let me know, if I can reproduce a working scenario, it would be very nice.

Thank you.

Sincerely,
Nhan Nguyen

I suggest you remove the PRU from the setup temporarily and try directly
reading the memory from C. This will be a lot easier to debug, and the
PRU has no chance of reading ADC values if you can't read them from the ARM.

As a guess, I suspect you don't have the ADC hardware setup properly and
are getting bus faults when reading. This will show up as an error if
you try to read the memory location from the ARM (making it easier to
debug). Make sure you have loaded a device tree overlay that enables
the TSC hardware (Touch Screen Controller = ADC) and populates an
appropriate state-machine instruction table to digitize the values you
are interested in. Unlike simpler microcontrollers, each major
subsystem in the AM335x can be powered up or shut down, and by default
most systems (ADC, PWM, etc) are powered down with their clocks disabled
until you explicitly enable them.

Once you can properly read the values from a raw memory location using
the ARM, the PRU should be able to read them as well.

Hi Charles,

Thank you very much for your answer. I manage to access it after enable ADC using ‘echo BB-ADC > /sys/devices/bone.capemgr.*/slots’ . Though I could only do it in kernel 3.8, later kernel (3.12) gives an error saying symbol ocp could not be found. I do not really know how to change the .dts to get it working . Anyhow, I will work with 3.8 for now.

Sincere,
Nhan Nguyen

Hi Charles,

Thank you very much for your answer. I manage to access it after enable ADC using ‘echo BB-ADC > /sys/devices/bone.capemgr.*/slots’ . Though I could only do it in kernel 3.8, later kernel (3.12) gives an error saying symbol ocp could not be found. I do not really know how to change the .dts to get it working . Anyhow, I will work with 3.8 for now.

There is no cape manager in V3.12

Regards,
John

Hi John,

Is there a way to enable ADC without using device tree? I couldn’t find a way to do it in the reference manual. Thank you.

Regards,
Nhan

You can enable the ADC without device tree, or without Linux if you
want. The TRM and data sheet have the details on how to power up/down
various parts of the system, and how to manage the clock generation for
the different sub-modules. However, it's fairly complicated, and I
suggest you let the Linux kernel drivers manage the clock and reset
trees for you, and continue to enable the ADC using device tree.

You can enable the ADC without device tree, or without Linux if you
want. The TRM and data sheet have the details on how to power up/down
various parts of the system, and how to manage the clock generation for
the different sub-modules. However, it's fairly complicated, and I
suggest you let the Linux kernel drivers manage the clock and reset
trees for you, and continue to enable the ADC using device tree.

Charles, I think Nhan is getting confused between the Cape Manager and
Device Tree. He was attempting to use Cape Manager to load the Device Tree
Overlay in V3.12 and I explained that there is no Cape Manager in V3.12.
His next question was how to enable ADC without DT.

Nhan, you can use DT in V3.12. Cape Manager is used to discover attached
Capes and to adapt pinmux and DT, which then loads the required device
drivers. The Cape Manager can also load and unload DT overlays while the
system is live. With V3.12, you cannot do this so you have to setup the DT
at boot time.

Regards,
John

Did you find how to enable ADC without device tree? I have the same problem like you.

This is an old thread, but the answer meight still be helpful:

Check out libpruio. Find the desired code in file src/pruio/pruio_init.p. It enables devices TSC_ADC_SS and GPIOs (if not up before).