PRU Internal clock

51 views
Skip to first unread message

alanmt...@icloud.com

unread,
Dec 7, 2018, 12:37:01 PM12/7/18
to BeagleBoard
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

Bill Bitner

unread,
Dec 7, 2018, 2:41:06 PM12/7/18
to beagl...@googlegroups.com
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

Charles Steinkuehler

unread,
Dec 7, 2018, 7:35:21 PM12/7/18
to beagl...@googlegroups.com
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.

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

alanmt...@icloud.com

unread,
Dec 8, 2018, 3:36:01 PM12/8/18
to BeagleBoard
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.
Reply all
Reply to author
Forward
0 new messages