From: eLinux.org

Ti AM33XX PRUSSv2

The PRUSS (Programmable Real-time Unit Sub System) consists of two
32-bit 200MHz real-time cores, each with 8KB of program memory and
direct access to general I/O. These cores are connected to various data
memories, peripheral modules and an interrupt controller for access to
the entire system-on-a-chip via a 32-bit interconnect bus.

PRUs are programmed in
Assembly, with most
commands executing in a single cycle and with no caching or pipe-lining,
allowing for 100% predictable timings. At 200MHz, most operations will
take 5ns (nanoseconds) to execute, with the exception of accessing
memory external to PRU.

Contents

This is a Work In Progress

Available PRU Resources

AM335x
PRUSS

Click here for a full list of register
mappings.

Per PRU

8KB program memory
Memory used to store instructions and static data AKA Instruction Memory
(IRAM). This is the memory in which PRU programs are loaded.

Enhanced GPIO (EGPIO)
High-speed direct access to 16 general purpose output and 17 general
purpose input pins for each PRU.

PRU0
pr1_pru_0_pru_r30[15:0] (PRU0 Register R30 Outputs)

pr1_pru_0_pru_r31[16:0] (PRU0 Register R31 Inputs)

PRU1
pr1_pru_1_pru_r30[15:0] (PRU1 Register R30 Outputs)

pr1_pru_1_pru_r31[16:0] (PRU1 Register R31 Inputs)

Hardware capture modes
Serial 28-bit shift in and out.

Parallel 16-bit capture on clock.

MII
standardised capture mode, used for implementing media independent Fast
Ethernet (100Mbps - 25MHz 4-bit).

A 32-bit multiply and accumulate unit (MAC)
Enables single-cycle integer multiplications with a 64-bit overflow
(useful for decimal results).

8KB data memory
Memory used to store dynamic data. Is accessed over the 32-bit bus and
so not single-cycle.

One PRU may access the memory of another for passing information but it
is recommend to use scratch pad or shared memory, see below.

Open Core Protocol (OCP) master port
Access to the data bus that interconnects all peripherals on the SoC,
including the ARM Cortex-A8, used for data transfer directly to and from
the PRU in Level 3 (L3) memory space.

Shared Between PRUs

Scratch pad
3 banks of 30 32-bit registers (total 90 32-bit registers).

Single-cycle access, can be accessed from either PRU for data sharing
and signalling or for individual use.

12KB data memory
Accessed over the 32-but bus, not single-cycle.

Local Peripherals

Local peripherals are those present within the PRUSS and not those
belonging to the entire SoC. Peripherals are accessed from PRUs over the
Switched Central Resource (SCR) 32-bit bus within the PRUSS.

Attached to the SCR bus is also an OCP slave, enabling OCP masters from
outside of the PRUSS to access these local peripherals in Level 4 (L4)
memory space.

Enhanced Capture Model (eCAP)

Industrial Ethernet Peripheral (IEP)

Universal Asynchronous Receiver/Transmitter (UART0)
Used to perform serial data transmission to the TL16C550 industry
standard.

16-bit FIFO receive and transmit buffers + per byte error status.

Can generate Interrupt requests for the PRUSS Interrupt Controller.

Can generate DMA requests for the EDMA SoC DMA controller.

Maximum transmission speed of 192MHz (192Mbps - 24MB/s).

Communication

Communication between various elements of the PRUSS or the wider SoC may
take place either directly, over a bus, via interrupts or via DMA.

The following lists will expose all possible communication approaches
for each likely scenario.

For communication via interrupts, please first read the section on the
PRUSSv2 Interrupt
Controller
.

Click here for a full list of PRUSS
Interrupts.

The current example PRU
loader

uses
UIO,
but this ideally should be replaced with
remoteproc rather than
poking at the registers from userspace. In the mean time, according to
this
discussion:

we can use the included script and load the uio_pruss userspace driver.

PRU to Host (PRU to ARM Cortex-A8)

Include the uio_pruss kernel driver by using modprobe uio_pruss or
the steps outlined above, if that does not work. Then in a project
include the header files for the am335x_pru_package.

  1. #define PRU_NUM0 0
  2. // Driver header file
  3. #include <prussdrv.h>
  4. #include <pruss_intc_mapping.h>

/* Then, initialize the interrupt controller data */

  1. tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;

/* Initialize the PRU */

  1. prussdrv_init ();

/* Get the interrupt initialized */

  1. prussdrv_pruintc_init(&pruss_intc_initdata)

/* Execute example on PRU0 where first argument is the PRU# and second
is the assembly to execute*/

  1. prussdrv_exec_program (PRU_NUM0, "./example.bin");

/* Wait until PRU0 sends the interrupt*/

  1. prussdrv_pru_wait_event (PRU_EVTOUT_0);

/* Clear the interrupt*/

  1. prussdrv_pru_clear_event (PRU0_ARM_INTERRUPT);

The PRU (in this case 0) will have the following in the example.bin file
to trigger the interrupt:

  1. #define PRU0_ARM_INTERRUPT 19
  2. MOV r31.b0, PRU0_ARM_INTERRUPT+16

Register 31 allows for control of the INTC for the PRU.

Host to PRU (ARM Cortex-A8 to PRU)

Interrupts

Each PRU has access to host interrupt channels Host-0 and Host-1 through
register R31 bit 30 and bit 31 respectively. By probing these registers,
a PRU can determine if an interrupt is currently present on each host
channel.

To configure

PRU to external peripherals

External peripherals to PRU

PRU to internal peripherals

Internal peripherals to PRU

Loading a PRU Program

Beaglebone PRU connections and modes


























































































































































































































































































































































































































PRU #R30(output) bitPinmux ModeR31(input) bitPinmux ModeBB HeaderBB Pin NameZCZ BallNameOffset RegDT OffsetInput ModeOutput Mode
00Mode_50Mode_6P9_31SPI1_SCLKmcasp0_aclkx990h0x1900x060x25
01Mode_51Mode_6P9_29SPI1_D0mcasp0_fsx994h0x1940x060x25
02Mode_52Mode_6P9_30SPI1_D1mcasp0_axr0998h0x1980x060x25
03Mode_53Mode_6P9_28SPI1_CS0mcasp0_ahclkr99Ch0x19C0x060x25
04Mode_54Mode_6P9_42(note1)mcasp0_aclkr9A0h0x1A00x060x25
05Mode_55Mode_6P9_27GPIO3_19mcasp0_fsr9A4h0x1A40x060x25
06Mode_56Mode_6P9_41(note2)mcasp0_axr19A8h0x1A80x060x25
07Mode_57Mode_6P9_25GPIO3_21mcasp0_ahclkx9ACh0x1AC0x060x25
014Mode_6N/AP8_12GPIO1_12gpmc_ad12830h0x030N/A0x25
015Mode_6N/AP8_11GPIO1_13gpmc_ad13834h0x034N/A0x25
0N/A14Mode_6P8_16GPIO1_14gpmc_ad14838h0x0380x06N/A
0N/A15Mode_6P8_15GPIO1_15gpmc_ad1583Ch0x03C0x06N/A
0N/A16Mode_6P9_24UART1_TXDuart1_txd984h0x1840x06N/A
10Mode_50Mode_6P8_45GPIO2_6lcd_data08A0h0x0A00x060x25
11Mode_51Mode_6P8_46GPIO2_7lcd_data18A4h0x0A40x060x25
12Mode_52Mode_6P8_43GPIO2_8lcd_data28A8h0x0A80x060x25
13Mode_53Mode_6P8_44GPIO2_9lcd_data38ACh0x0AC0x060x25
14Mode_54Mode_6P8_41GPIO2_10lcd_data48B0h0x0B00x060x25
15Mode_55Mode_6P8_42GPIO2_11lcd_data58B4h0x0B40x060x25
16Mode_56Mode_6P8_39GPIO2_12lcd_data68B8h0x0B80x060x25
17Mode_57Mode_6P8_40GPIO2_13lcd_data78BCh0x0BC0x060x25
18Mode_58Mode_6P8_27GPIO2_22lcd_vsync8E0h0x0EO0x060x25
19Mode_59Mode_6P8_29GPIO2_23lcd_hsync8E4h0x0E40x060x25
110Mode_510Mode_6P8_28GPIO2_24lcd_pclk8E8h0x0E80x060x25
111Mode_511Mode_6P8_30GPIO2_25lcd_ac_bias_en8ECh0x0EC0x060x25
112Mode_512Mode_6P8_21GPIO1_30gpmc_csn1880h0x0800x060x25
113Mode_513Mode_6P8_20GPIO1_31gpmc_csn2884h0x0840x060x25
1N/A16Mode_6P9_26UART1_RXDuart1_rxd980h0x1800x06NA
  1. *Note1: The PRU0 Registers{30,31} Bit 4 (GPIO3_18) is routed to P9_42-GPIO0_7 pin. You MUST set GPIO0_7 to input mode in pinmuxing.
  2. *Note2: The PRU0 Registers{30,31} Bit 6 (GPIO3_20) is routed to P9_41-GPIO0_20(CLKOUT2). You must set GPIO0_20 to input mode in pinmuxing.

Assembly

The complete list of PRU assembly instructions can be found at
TI
.

Four instruction classes

  • Arithmetic
  • Logical
  • Flow Control
  • Register Load/Store

Instruction Syntax

  • Mnemonic, followed by comma separated parameter list
  • Parameters can be a register, label, immediate value, or constant
    table entry
  • Example
    • SUB r3, r4, 10
    • Subtracts immediate value 10 (decimal) from the value in r4 and
      then places the result in r3 (or r3 = r4 - 10)

C Compiler

TI

GCC

Forth Compiler

Resources

Examples

Categories: