PRU Internal clock

I use the BeagleBone Black PRU for a very time critical task. I currently have registers that increment based on how many instructions I have just run and their type (SBBO’s for instance take more than the usual 1 clock cycle per instruction) so that I can keep track of time. I have seen somewhere that you can reset and read an internal clock on the BBB PRUs, but I just can’t seem to find that again.

Has anyone used this feature, and if so can you guide me on how to go about reading and resetting?

Thanks so much,

Alan

Hi Alan!

There is only 1 of this timer, so expect trouble if you try to use it on both PRU’s at the same time…
That said, the following should do what you want (from Mark Yoder’s PRU Cookbook). One count == 5ns, so you can do some pretty precise timing.

#include <pru_iep.h>

define TEN_US_DELAY 2001

CT_IEP.TMR_CNT = 0x0; // set the timer to 0

CT_IEP.TMR_GLB_CFG = 0x11; / set the timer running and also its multiplier for a 5ns per tick.

while ( CT_IEP.TMR_CNT < TEN_US_DELAY);

Bill Bitner

There's the Industrial Ethernet Peripheral, mentioned by Bill which
includes support for 8 timers.

In addition, there is an ECAP module within the PRU fabric (separate
from the other BBB ECAP timer modules).

But I think you may be thinking of the Cycle/Stall registers. You can
enable the cycle count register in the Ctrl register (CTR_EN bit), and
you can clear the cycle count when the counter is disabled, if desired.

Thanks to both of you, this is really helpful. Charles, this is what I was looking for and for this particular problem is what I need, but also thanks Bill I will have a look at this timer as well.