PRUSS and accessing ADC registers on Beaglebone Black

2,160 views
Skip to first unread message

Nhan Nguyen

unread,
Feb 19, 2014, 8:43:04 AM2/19/14
to beagl...@googlegroups.com
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

Charles Steinkuehler

unread,
Feb 19, 2014, 8:57:31 AM2/19/14
to beagl...@googlegroups.com
On 2/19/2014 7:43 AM, Nhan Nguyen wrote:
> 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.

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.

--
Charles Steinkuehler
cha...@steinkuehler.net

Nhan Nguyen

unread,
Feb 22, 2014, 8:40:10 PM2/22/14
to beagl...@googlegroups.com
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

John Syn

unread,
Feb 22, 2014, 9:05:39 PM2/22/14
to beagl...@googlegroups.com


From: Nhan Nguyen <chinh...@gmail.com>
Reply-To: <beagl...@googlegroups.com>
Date: Saturday, February 22, 2014 at 5:40 PM
To: <beagl...@googlegroups.com>
Subject: Re: [beagleboard] PRUSS and accessing ADC registers on Beaglebone Black

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
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nhan Nguyen

unread,
Feb 26, 2014, 9:05:12 AM2/26/14
to beagl...@googlegroups.com
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

Charles Steinkuehler

unread,
Feb 26, 2014, 12:07:25 PM2/26/14
to beagl...@googlegroups.com
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.
>> email to beagleboard...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>


--
Charles Steinkuehler
cha...@steinkuehler.net

John Syn

unread,
Feb 26, 2014, 3:06:57 PM2/26/14
to beagl...@googlegroups.com


On 2/26/14, 9:07 AM, "Charles Steinkuehler" <cha...@steinkuehler.net>
wrote:

>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
>email to beagleboard...@googlegroups.com.

Sungjin Chun

unread,
Mar 26, 2014, 1:57:00 AM3/26/14
to beagl...@googlegroups.com
Did you find how to enable ADC without device tree? I have the same problem like you.

TJF

unread,
May 26, 2014, 6:29:19 AM5/26/14
to beagl...@googlegroups.com
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).
Reply all
Reply to author
Forward
0 new messages