How to use PRU constants table?

335 views
Skip to first unread message

Karl Karpfen

unread,
Jul 15, 2016, 4:41:06 AM7/15/16
to BeagleBoard
Hi,

the AM335x TRM specifies a constants table for PRU which can be used for easier access of memory addresses. As an example: for I2C1 registers which originally use base-address 0x4802A000 a constant 2 is defined.

What I do not understand: how can one use these constants? How does the mapping from a constant to a base-address work where I have to add an offset in order to access desired registers?

Or is this an assembler-thingy only which can't be used out of PRU-C-Software?

Thanks!

Dennis Lee Bieber

unread,
Jul 15, 2016, 8:42:55 AM7/15/16
to beagl...@googlegroups.com
On Fri, 15 Jul 2016 01:41:06 -0700 (PDT), Karl Karpfen
<karlka...@gmail.com> declaimed the
following:


>Or is this an assembler-thingy only which can't be used out of
>PRU-C-Software?
>
Off-hand... "assembler-thingy"...

http://processors.wiki.ti.com/index.php/PRU_Assembly_Instructions#Load_Byte_Burst_with_Constant_Table_Offset_.28LBCO.29

Appears to be just two opcodes that make use of the constant table: the
linked Load, and the following Store,
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Greg

unread,
Jul 15, 2016, 2:59:12 PM7/15/16
to BeagleBoard
There is an example in the PRU support package:


Look in the examples folder for am335x.

Regards,
Greg

Karl Karpfen

unread,
Jul 18, 2016, 1:33:38 AM7/18/16
to BeagleBoard
Thanks, I found it in the PRU support package. But I wonder if this really saves some time/code...

John Syne

unread,
Jul 18, 2016, 2:03:41 AM7/18/16
to beagl...@googlegroups.com
The support package is just examples of how to use RemoteProc/RPMSG. Remember to use V4.02 for the V4.1 Linux Kernel and V5 for the V4.4 Linux kernel. The V4.02 uses mailbox events and the V5 uses interrupt events. If you want ARM sample code which interacts with the PRU firmware, look in the Linux source code /samples/rpmsg. 

Here is how to use the PRU support package:



Regards,
John




-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/3a31db16-a078-476f-928f-e1f50233c075%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

din...@gmail.com

unread,
Jul 20, 2016, 12:40:43 AM7/20/16
to BeagleBoard
Hi Karl,

These constants allow the C compiler to produce more efficient code. Of course you can also use them in assembly programs by explicitly using lbco/sbco instructions.

Let me give you an example how pru-gcc uses the constant table. Consider this C code snippet:
# define MYREG   ( * (volatile uint32_t *)(0x4802A000 + 0x24))
MYREG = 42;


Normally pru-gcc would output the following:
        ldi     r14, %lo(1208131620)
        ldi     r14
.w2, %hi_rlz(1208131620)
        ldi     r15
, 42
        sbbo    r15
, r14, 0, 4

But you can tell the compiler that this address base is special (btw, already defined for you in <pru/io.h>):
#pragma ctable_entry 2 0x4802a000
Then the compiler can produce a much shorter instruction sequence:
        ldi     r14, 42
        sbco    r14
, 2, 36, 4

TI's compiler uses a different syntax for the constants declarations, but essentially does the same optimization.

Regards,
Dimitar
Reply all
Reply to author
Forward
0 new messages