On Wed, Oct 19, 2016 at 4:50 PM, Arthur Caio <[email protected]> wrote:
> Hello you all! > > I need to calculate hot much time it takes for an input to go from LOW to > HIGH and then to LOW again. Basically, I want to know the period of a > square wave generated by the LM555 timer. > > I am using Qt Creator and programming in C++. > > I am having trouble at programming this code in C++ for the beaglebone. > > Do you guys have any piece of code in C++ that may help me? > I do not personally know of any code for this specific case. However, and with that said. Your best bet aside from writing a Linux module specifically for this is to use and interrupt, and some form of Linux time API call. As for userspace interrupts. This is not really possible. As this would slow down the OS too much because of application context switching. However, there is something very close to just as good. For this from a userspace application. You can setup a blocking read form the sysfs gpio "value" file. Like so: $ ls /sys/class/gpio/gpio2 active_low device direction edge power subsystem uevent *value* This is actually more complicated than it may seem initially however. As I believe poll(), and select() both will return immediately if you do not configure the "edge" file correctly. Instead of repeating what's already been described on the internet, I'll leave you with this link, which describes it this very well I think: https://www.linux.com/learn/beaglebone-black-how-get-interrupts-through-linux-gpio Then once you have that figured out, all you really need is a before, and after timestamp. Which is described very well in the multiple answers to this stackoverflow question; http://stackoverflow.com/questions/11765301/how-do-i-get-the-unix-timestamp-in-c-as-an-int -- 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/CALHSORpHuBqJd0FxbYrfr0zfsOfvY6bk886pe6C%2B5t9NE54p7w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
