Sub microsecond time measurement-again

Status
Not open for further replies.

BobQ

Member
I'm using part of freqMeasureMulti to measure time intervals without using flextimer. flextimer is a bit much for me to understand and this is work around that uses documented and tested commands. I use a 74HC4046 PLL chip and
"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."
The 74HC4046 has 2 inputs and an output (pin 1) that goes high when the first input goes high and goes low when the second input goes high, an edge-triggered RS flip flop. Using freqMeasureMulti I can measure the time between first edge and second edge with resolution based on bus clock instead of 1 usec resolution. Compiling for 48 MHz gives a bus clock of 48 MHz. (72 MHz gives bus clock of 36 MHz).

In the past I also tried ARM_DWT_CYCCNT; and SYST_CVR; but I got occasional bad readings. As Paul mentioned in an earlier thread
"These interrupt approaches have many pitfalls, as we're seeing in this conversation. "
I think flextimer is a better approach for those who understand it. Just thought I'd mention this option.
 
There's a previous thread, "Teensy 3.1 Time Measurements", started 30 Apr 2015, that shows some results for ARM_DWT_CYCNT. Probably too much information but it appears some task occasionally stops ARM_DWT_CYCNT. I also found the code did not execute correctly when I power cycled the teensy and ran it stand alone.
I did a similar test using systick and found occasional bad readings. The details varied if I changed interrupt priorities. No problem with power cycling. I didn't post that test.
I see no errors using freqMeasureMulti.
 
Long ago, like 2013 to 2014 time frame, the bootloader interfered with the DWT stuff a few milliseconds after the program started running. It caused trouble with Neopixel, which uses ARM_DWT_CYCNT. This bug was fixed a very long time ago and should not be present in any modern Teensy boards. But there are certainly some very old thread on this forum which mention this old problem. Just in case anyone's wondering, it was fixed ages ago.
 
Status
Not open for further replies.
Back
Top