Does BBB have a running counter that I can access?

370 views
Skip to first unread message

Bill Gray

unread,
Feb 2, 2015, 3:40:19 PM2/2/15
to beagl...@googlegroups.com
Hello,

I'm writing a program for the PRU to determine the RPM of motor and do a number of other things as well.

Instead of having the PRU run a loop of pre-determined length to meter time, I would prefer to be able to access some hardware counter that is ticking away to see how many ticks have passed since the last event.  This way, the other things going on on the PRU won't screw up my timing measurements.

From the technical reference I see that there are a number of timers available on the am335x chip.  Further, I see that my cape-universal is turning on number of things in the /sys/devices/ocp.3/ directory that have a ".timer" suffix.

But when I use devmem2 to look at the registers for the timers as called out in the technical reference, I don't see anything ticking???

Is there a counter some where that is just ticking away that I can use to mark time?  How can I access it?  How can I turn it on?

Thanks,

Bill




Bill Gray

unread,
Feb 2, 2015, 4:32:36 PM2/2/15
to beagl...@googlegroups.com
Ok...

A bit more research and I have found that DMTIMER2 is running.  I must have typed int he wrong address the first time I checked.

As with all things memory map, the control of this timer is a bit cryptic, but is looks as though the TCRR which is to say the actual incrementing register is available at 0x4804003C.

It looks like DMTIMER1 is sort of a wierd 1 of clock, and that DMTIMER 3-7 are not running at all... interestingly devmem2 generates a buss error when I try to read their registers.  I'm not sure why that would happen?

It seems that the rate that DMTIMER2 is incrementing is actually controlled from CLKSEL_TIMER2_CLK which is in the CM_DPLL register bank with is located at 0x44E00500 with an offset of 8.

This indicates that DMTIMER2 is being fed by the "system clock".  Oddly according to my testing, it appears that this "system clock" is not actually a 1Ghz clock, but rather a 25Mhz clock.

This is all fine for my purposes, but I'm really not sure how it is that DMTIMER2 got turned on, or how to turn on the other DMTIMERs.

Thanks,

Bill

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/7Zz6w_pk970/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Gray
Velkess
415 407 7356

TJF

unread,
Feb 3, 2015, 10:35:02 AM2/3/15
to beagl...@googlegroups.com
When this is your aim

Am Montag, 2. Februar 2015 21:40:19 UTC+1 schrieb Bill Gray:
... to determine the RPM of motor ...

why don't you use a QEP module in the PWMSS-[1-3] subsystems? (Or, when you neither need position nor direction information, you can use the CAP feature on PWMSS-CAP[1-3] or TIMER[4-7].)

BR

Bill Gray

unread,
Feb 3, 2015, 1:30:47 PM2/3/15
to beagl...@googlegroups.com
Thanks for the suggestion.

The quadrature encoding system looks really cool.

For me right now, I've already got all of these events happening on the PRU, and I just need to measure the time between them so a simple counter is what I am after... and I've found one, so I will use it.

But I am still confused...

Why is it the DMTIMER2 running and not all of the others?
Why am I not able to access the registers of the other timers using devmem2?
Is there some other process that is using DMTIMER2 that I should be aware of?
Timers are being called out in cape-universal, and then show up in /sys/devices/ocp.3/ but how do I make use of them?

Answers to any of these questions would be super helpful!

Thank you,

Bill



--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/7Zz6w_pk970/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TJF

unread,
Feb 3, 2015, 3:55:14 PM2/3/15
to beagl...@googlegroups.com
I thaught you're on PRU. Why are you looking for sysfs?

TIMERs can only get accessed via OCP master port. When you need a timer on the PRU, first have a look at the PRU-IEP module timer (32 bit, 200 MHz).

BR
Reply all
Reply to author
Forward
0 new messages