Tool/software: TI C/C++ Compiler
I'm trying to make PRU talk to ARM host in a beaglebone. The difficulty is I want to check on both ends to see if the other side has sent any message, in a non-blocking fashion.
On the host side, just polling and reading on /dev/rpmsg_pru30 and /dev/rpmsg_pru31 seems to be good enough.
On the PRU side, I'm having a problem with too many interrupts.
I'm using
CT_INTC.SICR = FROM_ARM_HOST;
to clear the interrupt, and
#define CHAN_PORT 30 #define CHAN_DESC "Channel 30" #define TO_ARM_HOST 16 #define FROM_ARM_HOST 17 #define INT_MASK ((uint32_t)1 << CHAN_PORT) #define FROM_ARM_MASK ((uint32_t)1 << FROM_ARM_HOST) if (((__R31 & INT_MASK) && (CT_INTC.SECR0 & FROM_ARM_MASK)) != 0) {...}
(Both FROM_ARM_HOST and TO_ARM_HOST are set using pru_rpmsg_init.)
to check for the interrupt for PRU0. I also clear the interrupt after every read.
It seems to work fine when I"m just receiving message from the host. However, if I send a message from PRU0 to ARM host, the interrupt is on but since there was nothing to read from ARM to PRU0, the reading fails.
It doesn't help if I immediately clear the interrupt after the send. The clearing seems to work, however, if I send message from PRU0 to ARM, wait for about 4E5 cycles, clear the interrupt, wait for the next message from ARM, then it works (the interrupt is cleared and next interrupt from ARM to PRU0 is registered normally).
I don't understand why the interrupt on this two way channel is not reliable. Is there something I did wrong? If I try to clear the interrupt with CT_INTC.SICR_bit.STS_CLR_IDX = FROM_ARM_HOST I see the same problem. If I check the interrupt simply with if (__R31 & HOST_INT) like in the lab examples, the flag is always true and never gets cleared.