Skip to main content
Visitor II
October 2, 2026
Question

VL53L4CD ULD – CalibrateXtalk() wraps negative crosstalk to ~65k, invalidating all subsequent ranging

  • October 2, 2026
  • 1 reply
  • 8 views

Hi,

We found an issue in VL53L4CD_CalibrateXtalk() (ULD v2.2.2, as shipped in X-CUBE-TOF1 v3.4.3).

When the measured average distance is slightly greater than the target distance, the computed crosstalk is negative:

c

tmp_xtalk = (float_t)1.0 - (AvgDistance/TargetDistance);
tmp_xtalk *= (AverageSignal/AverageSpadNb);

The function only checks the upper bound (tmp_xtalk > 127.0). It then casts the negative float to uint16_t, which is undefined behavior in C. On our platform the value wraps. For example, −3 kcps is returned as 65533 and reported as a successful calibration, and the register is written with 64000, which corresponds to about 125 kcps.

With that value applied, crosstalk compensation removes nearly the entire return signal: 125 kcps/SPAD × 77 SPADs ≈ 9,600 kcps, against a raw signal of about 9,700 kcps. Every subsequent measurement fails with "signal below threshold" (range_status 2, distance 8191 mm).

Setup: offset calibrated at 100 mm, then crosstalk calibration on a white target at 200 mm, 10 samples. The issue is intermittent: a repeated calibration sometimes returns a small positive value and ranging works normally.

We understand that 200 mm on a white target is not the recommended calibration condition. Even so, the function should handle that case safely rather than leave the sensor unusable.

Thanks,

Ondrej Pilat

1 reply

Graduate
October 5, 2026

There might be a math issue but first let’s look at the setup. When trying to find crosstalk you are looking for the number of photons returned from the coverglass, and that is complicated by all those photons coming from the target. 

Do this experiment…

Range on a movable target and find that point where the range is being under-reported by 10 or 20 percent. This distance is entirely dependent on the quality of your coverglass. With a white target this is going to be a longer distance than with a black target. (The number of zero-distance photons gets overwhelmed with a strong close target.)

Then use this distance and target to do your crosstalk measurement. 

I’m thinking it’s the white target and the close (20cm) distance that goofing up your calibration.

  • john
"If this or any post solves your issue, please mark them as ""Accept as Solution"". It really helps the next guy.And if you notice anything wrong do not hesitate to ""Report Inappropriate Content"".I am a recently retired ST Employee. My former username was John E KVAM."