Can a PRU tell if it's PRU0 or PRU1?

77 views
Skip to first unread message

Ken Shirriff

unread,
Jan 21, 2017, 6:56:08 AM1/21/17
to BeagleBoard

Is it possible for a PRU to know if it is PRU0 or PRU1? I want to run the same code on both PRUs but have it do slightly different things [*]. I guess I could write a "0" to PRU0's RAM and a "1" to PRU1's RAM and the PRU code could test this. But is there a more direct way, such as reading a config register? I looked over the Technical Reference Manual but couldn't find anything.

[*] Specifically, I want the PRU code to send an event to the ARM, with PRU_EVTOUT0 from PRU0 and PRU_EVTOUT1 from PRU1, so the ARM code knows which PRU sent the event. But I can't see how to do that without the PRU knowing if it is PRU0 or PRU1.

Thanks,
Ken

Greg

unread,
Jan 21, 2017, 1:26:56 PM1/21/17
to BeagleBoard
So you are saying the firmware loaded to both PRUs has to be exactly the same?
You can't use a slightly different #define to make a different constant in PRU0 vs PRU1?

Regards,
Greg

Greg

unread,
Jan 21, 2017, 2:15:22 PM1/21/17
to BeagleBoard
I thought of another way.  Kind of crude, but it might work.  This would allow the firmwares to be identical.

Assuming you have a spare PRU GPI in each, you could set the pull-up on one pin, and a pull-down on the other.
Then you just read the appropriate value of the bit in __R31.  Of course you would have to carefully select the pins so they are the same bit in __R31.
So if those pins are spoken for in your application, this isn't going to work.

Hopefully someone will know a method which is baked-in to the system.

Hunyue Yau

unread,
Jan 23, 2017, 8:15:48 PM1/23/17
to beagl...@googlegroups.com, Ken Shirriff
You could have the ARM side write a unique number at a known offset into into
the PRU's DRAM area.

Then have the firmware read it from 0x0000+offset.

Each PRU's DRAM is mapped into 0x0000 (as seen from the PRU).
The ARM sees PRU0's DRAM at PRUBASE + 0x0000 and PRU's DRAM at PRUBASE +
0x2000.

For eample:

So before loading, write 0x10 to PRUBASE + 0x0004 and 0x20 to PRUBASE +
0x2004. 0x10 and 0x20 are just 2 unique values.
Then the PRU firmware can do something like (psuedo code):
If (*(0x0004) == 0x10) {
/* On PRU 0 */
} else {
/* On PRU 1 */
--
Hunyue Yau
http://www.hy-research.com/
Reply all
Reply to author
Forward
0 new messages