On Fri, Dec 15, 2017 at 2:25 PM, Dennis Lee Bieber <[email protected]> wrote: > On Fri, 15 Dec 2017 09:05:30 -0800 (PST), > [email protected] declaimed the > following: > >>I would like to use the eCap feature to measure the frequency of a square >>wave, preferably with Python. I see examples for generating a square wave >>using the BBIO.PWM module but I can't find anything for reading the eCap. >>The BBIO.Encoder module looks promising. Can I use this to measure the >>frequency of a single square wave or do I need a quadrature encoder? >>Thanks. > > Which "BBIO"? PyBBIO or Adafruit_BBIO? > > Based upon the documentation for the latter -- it is not a "frequency" > measurement but a counter (up/down) based upon the transitions of a > quadrature signal (ie; TWO square waves 90 deg out of phase). PyBBIO docs > look to be similar. > > A quick Google seems to lean towards either kernel module with > interrupts on GPIO pins, or using the PRU for a tight-loop counter, if > accuracy is needed. > > If some irregularity is acceptable, user-mode GPIO loop may be okay -- > though probably by memory mapping the GPIO pins rather than using the sys > filesystem access. And both of these will likely not be fast enough if > using interpreted Python. > > Unfortunately, the PWM modules in the Python libraries are designed > solely for PWM output -- even though the eCAP hardware is part of the PWM > hardware. cf: TRM SPRUH73P section 15.3.3.1 > > https://e2e.ti.com/support/embedded/linux/f/354/t/399439 seems to imply the > eCAP could be accessible via the sys filesystem (but may need some work). > That could make the latency issue moot, if you can trigger a one-shot > capture (for four time-stamps?) and then read the time-stamps later to > compute frequency. OTOH, > https://e2e.ti.com/support/arm/sitara_arm/f/791/p/393325/1388948 implies > the kernel doesn't support eCAP...
We do have an iio ecap driver (IIO_TIECAP) in the v4.4.x-ti branch, originally written-by Matt Porter, but it never made it to mainline: https://github.com/RobertCNelson/ti-linux-kernel-dev/tree/ti-linux-4.4.y/patches/drivers/ti/iio It needs to be re-ported to v4.9.x/v4.14.x, one of the GSOC users was working on it last summer i believe.. Regards, -- Robert Nelson https://rcn-ee.com/ -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYh6JE8BozH%3DOuuyMxxXnGkGqyaU%3DtuetfaxnCsTahkcyQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
