From: <edwin.j....@gmail.com> Reply-To: <beagleboard@googlegroups.com> Date: Thursday, May 22, 2014 at 4:53 PM To: <beagleboard@googlegroups.com> Cc: <ej...@yahoo.com> Subject: [beagleboard] Beaglebone Black: Reading GPIO at High Frequencies
> > I would like to continuously read the status of an IO line on my Beaglebone > black. The code I pasted below is a section of my software looking for rising > and falling edges. Is there a way in Linux to read the status of that line > without having to open and close the same file that is faster? The method I > have below works, but only at really low frequencies. > > I am trying to read the IO approx. 15kHz. Doing this from user space using the SYS filesystem is going to be slow. You have two options in Linux: 1. Use mmap and read/write directly the GPIO registers 2. Use a kernel module or device driver to read/write the GPIO registers However, even at 15KHz, the Linux kernel will be too slow because of scheduling and interrupt latency. I suggest you try to do the high speed stuff with the PRU and then interface with Linux for the high level data manipulations. Regards, John > > Thanks > > > while( buf[0]=='0' ) { > memset(adc_drdy, 0, sizeof(adc_drdy) ); > if((j = fopen ( "/sys/class/gpio/gpio65/value", "r" )) == NULL) { > //printSerial("Unable to read input file"); > } > else { > fgets(adc_drdy, sizeof(adc_drdy), j); > strcpy(buf, adc_drdy); > //fprintf(j, "%s", adc_drdy); > fclose(j); > } > system("echo 0 > /sys/class/gpio/gpio61/value"); > printf("%c\n", buf[0]); > //if(ADC_DRDY=='1') break; > } > while( buf[0]=='1' ) { > > memset(adc_drdy, 0, sizeof(adc_drdy) ); > if((j = fopen ( "/sys/class/gpio/gpio65/value", "r" )) == NULL) { > //printSerial("Unable to read input file"); > } > else { > fgets(adc_drdy, sizeof(adc_drdy), j); > strcpy(buf, adc_drdy); > //fprintf(j, "%s", adc_drdy); > fclose(j); > } > system("echo 1 > /sys/class/gpio/gpio61/value"); > printf("%c\n", buf[0]); > //if(ADC_DRDY=='0') break; > } > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.