FreqMeasure used to measure from rising to falling flange?

DavidSP

New member
Hi, I need to measure the length/time of a puls that is from 40ns to 4us (maybe up to 200us). In other words the time from rising to falling edges. Can I use FreqMeasure for that? To my understanding it measure the time from rising to rising. I tried to understand the FreqMeasure.ccp with the purpose to change it, but I have to give up on that.

Dos anyone have an example code for measuring a puls length of 40ns? A resolution of 10ns or 20ns is ok.

I have a Teensy 4.0
 
See the examples for the FreqMeasureMulti library. With the standard CPU frequency of 600 MHz, the FlexPWM clock is 150 MHz, so you can get about 6 ns resolution. The begin() function has a parameter to define what you want to measure. The default is rising edge to rising edge, but there is an option for rising edge to falling edge. The terminology for that parameter uses the terms "mark" and "space", and I can never remember how those relate to high and low. You can test by looping back a pin and configuring it for PWM with a small duty cycle.
 
Thankes Joepasquariello! It worked...

Link for FreqMeasurMulti examples I used: https://github.com/PaulStoffregen/F...Serial_Output/Single_PWM_in_Serial_Output.ino

"Mark" and "Space" explanation:
  • FREQMEASUREMULTI_SPACE_ONLY -> A new value becomes available at each rising ramp and contains the time since the previous falling ramp. Thus, only the "low time" of the signal period is returned
  • FREQMEASUREMULTI_MARK_ONLY -> A new value becomes available at each falling ramp and contains the time since the previous rising ramp. Thus, only the "high time" of the signal period is returned
 
Back
Top