Hi everyone!
I wanted to know if there is someone else who is having trouble running *this
example*
<https://github.com/beagleboard/am335x_pru_package/tree/master/pru_sw/example_apps/PRU_industrialEthernetTimer>
available in the am335x_pru_package.
It uses PRU1 to iniialize the IEP and then send an interrupt (EVTOUT1) to
the ARM who is waiting for it (prussdrv_pru_wait_event)
After make and build, running
sudo ./PRU_industrialEthernetTimer.out gives me this:
-> initializing the PRU
-> waiting PRU event...
-> This should take nearly 10000000 us...
****
the .p code is:
.origin 0
.entrypoint start
#include "PRU_industrialEthernetTimer.hp"
start:
// Copy the TICKS value from PRU shared memory first addr to r0
lbco r0, CONST_PRUSHAREDRAM, 0, 4
// timer configuration
// CMP_INC = 1
// DEFAULT_INC = 1
// CNT_ENABLE = 1
mov r1, 0x0111
sbco r1, CONST_IEP, 0x0, 2
lbco r1, CONST_IEP, IEP_TIMER_COUNT, 4 //read the timer counter
WAIT_LOOP:
lbco r2, CONST_IEP, IEP_TIMER_COUNT, 4 // read the timer counter
sub r2, r2, r1 // r2 = r2 - r1
qblt WAIT_LOOP, r0, R2 //if(r2 < r3) branch;
END:
mov r31.b0, PRU1_ARM_INTERRUPT+16
halt
the .c code is:
#include <stdio.h>
#include "prussdrv.h"
#include <pruss_intc_mapping.h>
// Delay in microseconds that PRU will expect to trigger the interruption in
// the Cortex main processor
#define DELAY_US 10000000u // Max. value = 21474836 us
// Convertion of the DELAY_US in PRU timer ticks
// PRU timer tick frequency = 200 MHz
// PRU timer tick period = 5 ns
// Number of ticks (TICKS) = (DELAY_US * 1000) / 5
#define TICKS ((DELAY_US / 5u) * 1000u)
// PRU number can be 0 or 1
#define PRU_NUM 1
// Path to binary that will be load in PRU
#define PRU_BINARY "./obj/PRU_industrialEthernetTimer.bin"
// Local function
static void write_pru_shared_mem ( void);
int main(void)
{
unsigned int ret;
tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;
printf("\t-> initializing the PRU\n");
prussdrv_init();
ret = prussdrv_open(PRU_EVTOUT_1); // Open PRU Interrupt
if (ret) {
printf("\t* prussdrv_open open failed!\n");
return (ret);
}
prussdrv_pruintc_init( &pruss_intc_initdata);
write_pru_shared_mem ();
prussdrv_exec_program (PRU_NUM, PRU_BINARY); // Load/exec the bin
in PRU
printf("\t-> waiting PRU event...\n");
printf("\t-> This should take nearly %u us...\n", (unsigned
int)DELAY_US);
prussdrv_pru_wait_event (PRU_EVTOUT_1);
printf("\t-> PRU event received.\n");
printf("\t-> closing the program...\n");
prussdrv_pru_clear_event (PRU_EVTOUT_1, PRU1_ARM_INTERRUPT);
prussdrv_pru_disable(PRU_NUM);
prussdrv_exit ();
return 0;
}
// Function to map and store the TICKS in the PRUs shared memory
static void write_pru_shared_mem ( void)
{
void *sharedMem;
unsigned int *sharedMem_int;
prussdrv_map_prumem( 4, &sharedMem); // Map shared PRUs memory
sharedMem_int = (unsigned int*) sharedMem;
// Writes in the PRUs shared memory in the first addr
sharedMem_int[0] = (unsigned int)TICKS;
}
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.