DS-TWR algorithm, too wide range of measurements

Hi!
I do a sequential survey of anchors with one tag on the DS-TWR algorithm and get a large spread of TOF, about (sizeof(DWT_TIME_UNITS))(10 - 30). What could be the problem?
Thank you very much!

Are you handling counter rollovers correctly? This can give some random and very large values but only on occasional measurements, it’s rare enough that it won’t impact most measurements.

Similarly are you handling negative time of flight values correctly? With a short ToF it doesn’t take much of a clock difference to result in the time of flight to come out as negative in one direction. Once you combine this time with the too high value for the other direction things all work out correctly but if you are using unsigned variables in the calculations then this could give some odd results.

AndyA, thanks for reply!

Sorry.Andy, I’m trying “ex_05a_ds_twr_init” and “ex_05b_twr_resp” from “dw1000_api_rev_xxx\examples”
I’ve combine these code into one, and the tag and anchors roles are hardcoded and depends of my choose…
This code use dwt_isr(), has abt. 80 uS IRQ latency and ints work well.
But still have large swing of Tround1,abt. 20-30 systime units. (this is on tag, initiator side)
I don’t understand what it is.