How to wait for rising edge with pruss?

159 views
Skip to first unread message

JJ

unread,
Dec 31, 2014, 6:23:11 AM12/31/14
to beagl...@googlegroups.com
So, how to set rising edge detection in pruio-lib without the following while-loop:

pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1);
int gpiovalue;

while(1) {
    gpiovalue
= pruio_gpio_Value(io, PIN);
   
if (gpiovalue == 1) {
       
///capturedatacode...

     
}



I have a device and it sends simple binary data which I have to capture. But the above code uses CPU a lot (is it normal for PRU if it causes 40% CPU usage, I thought it is independent from the main CPU?). Any help is appreciated.

TJF

unread,
Dec 31, 2014, 9:40:17 AM12/31/14
to beagl...@googlegroups.com
The PRUSS don't cause any CPU usage. You can reduce CPU usage by adding a nsleep() call to your while loop. Anyway, the max. speed of pulling the GPIO state (as in your while loop) is limited to approx. 140 kHz.

An alternative is to configure a GPIO interrupt
  1. Map an interrupt to any channel (except /dev/uio5, which is used by libpruio).
  2. Write a callback to handle the interrupt and install it.
  3. Configure the GPIO interrupt controller.
  4. Download the configuration (pruio_config(), RB and MM mode need a further start command).
As you can see this isn't trivial and needs advanced programming skills. You've to find a way to reset the interrupt status flag, which isn't supported by libpruio ATM.

Your problem description isn't very detailed. It may also be an option to use the General-Purpose Inputs (R31) of the free PRUSS in 28-bit shift mode to capture the signal at high frequencies.

BR
Reply all
Reply to author
Forward
0 new messages