Additionally, I'm not really sure if the above description I gave will be
fast enough, If you're very careful in how you structure your code, and
making sure not to use function calls that switch back and forth between
userspace / kernel space. I think it could be. However, if it is not fast
enough still, you can use one of the PRU's to trap interrupts on a pin. But
here the only missing piece I am not sure how you could generate a time
stamp in a timely fashion. No pun intended.

Something to be aware of. If you're going to use something like printf().
That would definitely slow down such an application. *UNLESS* you were to
pipe the output of that application to a file. LIke: ./foo > somefile.txt

On Wed, Oct 19, 2016 at 8:31 PM, William Hermans <yyrk...@gmail.com> wrote:

>
>
> On Wed, Oct 19, 2016 at 4:50 PM, Arthur Caio <arth...@gmail.com> 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 beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CALHSORpKm%3DatwpZyZ780rayeFb74sK7m6h7ZN%3DQQmb3yj9D6UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to