Does BBB have a running counter that I can access?


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?




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.



When this is your aim

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,


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).