Hi,
I'm using ePWM0 to trigger interrupts in the PRU (AM3358, Beaglebone Black). For some reason, these interrupts are always triggered twice. Once on CNT_PRD and once just after this.
Relevant code:
#define HOST_INT_NUM 1
#define INT_CHAN_NUM 1
#define PWM0_PRD_EVENT 43
[init ePWM0 to up/down counting, no clock divisor, event on first period]
[init INTC to trigger host interrupt HOST_INT_NUM on channel INT_CHAN_NUM with source from event PWM0_PRD_EVENT]
MOV regAddr, EPWM0_BASE
PWM_EVENT_WAIT:
WBS r31, #(30+HOST_INT_NUM)
[...do something for about 60cycles...]
//Clear PWM interrupt flag
LDI regTmp0.b0, PWM0_PRD_EVENT
SBCO regTmp0.b0, CONST_PRUINTC, OFS_INTC_SICR, 1 //Clear pending sys event interrupt
//Clear PWM event flag
LDI regTmp0.w0, 1
SBBO regTmp0.w0, regAddr, OFS_PWM_ETCLR, 2
JMP PWM_EVENT_WAIT
The first event is triggered as expected after about 4*PWM_Period Cycles (PRU at 200MHz, PWM_Clk at 100MHz, up/down counting). The second event is triggered with a latency of about the runtime of the outer loop. It seems to me as the clearing of the flags doesn't propagate so that WBS would block. Is there any better way to do that?