BeagleBone PRU help

Hi, I’m trying to make a simple PRU program to count transitions on GPIO 0. I just adapted the gpio Toggle example from the PRU SDK and modified it trigger on PRU system event 57 (GPIO0), but for each pulse I send it (via another GPIO output pin), the counter counts 20k times instead of 1.

Can anyone suggest why it’s counting so many times? I definitely clear the system interrupt status flag (SICR) after each interrupt. Are the GPIO interrupts level sensitive or edge triggered? The AM335x programming manual says “The type of all system interrupts is pulse,” but the pulse type is shown separately from the edge type?

(source code attached)

PRU_gpioToggle.p (2.01 KB)

PRU_timer2Interrupt.hp (4.79 KB)

OK, I’ve found the problem. I wasn’t clearing the GPIO interrupt flag (GPIO_IRQSTATUS_0 & GPIO_IRQSTATUS_1). I was only clearing the PRU interrupt flags, which isn’t sufficient.

Also, to save you some trouble, make sure PRU: SYSCFG is configured so that the OCP unit is on. This is needed for the PRU to access external memory:

(PRU access to ddram on am335x / beaglebone)
http://e2e.ti.com/support/dsp/sitara_arm174_microprocessors/f/791/t/167319.aspx#610260

We’ve discussed this on the list, and it’s on the path to being fixed by some mods to the clock tree configuration that will make it so that when you enable the clock domain it takes it out of reset. What you’re doing now is a good temporary fix, and you can look forward to a more permanent solution very soon. (The TI kernel apparently already has it; search this mailing list if you want to see the patch Jason Winnebeck and I wrote, though the TI approach is more inline with clocktree’s intended use and is probably the better overall solution once merged into Angstrom).