This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How I can do this measure from square waves?

Hi, I'd like to know if there is a way to subtract two different square waves that are coming from two different input pins and then measure the pulse width (or the frequency) of this resulting wave. Is it done by any specific function?

Thanks in advance

  • You will have to use the GPIOTE module to keep track of the state of the two input pins, i.e. configure it to generate interrupts whenever the input pins go from low to high or from high to low. In the interrupt handler you keep track of the state with two global variables and based on these two variable you can find the state of the two square wave subtracted form one another. In order to measure the pulse width you will have to start a timer when the resulting square wave transitions from low to high and stop it when it goes from high to low.

Related