I’m quite sure that you can not get this resolution from linux user space on the humble 1Ghz (max) BBB.
Why did you post this to the ‘pru’ topic? That is the right track, using the pru which is NOT PREEMPTIVE, you can write an ‘asm’ program (or maybe a ‘c’ program) that will (easily) output a stable 100us duration pwm… What duty cycle are you thinking of implementing?
If this MUST be ‘c’, and it MUST be on the BBB, then I think someone is trying to steer you to the PRU.
if this doesn’t have to be ‘c’, but you only have a BBB, then I’d do it with the pwm peripheral built in to the system. See the TRM - SPRUH73P – October 2011 – Revised March 2017 — chapter 15
or modify the details of my post here: Help with Device Tree, Trying to expose kernel pps - #28 by gomer
(but that would be cheating if this is a school project, wouldn’t it?)
good luck,
gomer
OOOPS… since my reply, I have taken a closer look at your code and realize that you are not trying to generate a PWM signal, but that you are trying to measure an existing PWM signal. (my fault for responding too quickly).
HOWEVER, my suggestion for familiarizing yourself with Chapter 15 of the TRM still might be fruitful. … in fact, if I was doing this in ASM on the PRU, I would use a higher resolution PWM signal as an application clock to assign the time to the signal under test.
in this post:
i describe a possible solution to a similar problem using a pwm signal as an application clock. If YOUR pwm signal is very high resolution, say 1us, this may be the best way to measure time between pulses of the signal under test.
good luck,
gomer