I am trying to understand how to take advantage of the pru to see if I can use it in my application.
I am trying to synchronize the pru execution from the host. I am using the c libraries, which could be a proble. What I am doing is simple enough that I don’t think this should be a problem unless it really just doesn’t work.
My pru code looks like this:
for (i = 0; i < 3; i++){
waitForHost()
// " CLR R31, R31, 30 \n"
// " WBS R31, 30 \n"
// " CLR R31, R31, 30 \n"
readInstruction();
// read from shared memory location
// do work for instruction
notifyHost()
// " LDI R31.b0, PRU0_ARM_INTERRUPT + 16 \n"
}
the host loop is:
// Initialize the pru
for (i = 0; i < 3; i++){
// write to shared memory location
writeInstruction();
// Tell the pru to read the instruction
notifyPru();
// prussdrv_pru_send_event(ARM_PRU0_INTERRUPT);
// Wait for pru to complete the operation
waitForPru();
// prussdrv_pru_wait_event(PRU_EVTOUT_0);
// prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT);
}
For debugging the pru writes the loop index to shared memory location 0.
As is, the first time the host reads the debug location, its value is 2 and never is 0 or 1.
It is as if the first time the pru is notified, it runs to completion, not stoping for the waitForHost at the top of the loop.
If I comment out the notifyPru() in the host, the host hangs waiting for the pru because the pru is still waiting.
Any help would be appreciated.