2025-10-01 10:51 AM
Hi,
I asked for help because my measurements took >> 15 seconds (up to 30s) in:
https://community.st.com/t5/imaging-sensors/vl53l1-measurement-takes-up-to-30-seconds/td-p/843640
Now after hours of debugging i found a bug in the API at least for platforms where an Integer is not 32 bit, in:
vl53l1_core_support.c:114
the code is:
pll_period_us = (0x01 << 30) / fast_osc_frequency;
but on AVR uC like atmega644 0x01 is 16 bit wide. Which leads to pll_period_us = 0.
The wrong value messes up all tim_cfg and gen_cfg, and introduces weird behavior.
Fix:
pll_period_us = (0x01UL << 30) / fast_osc_frequency;
Telling the compiler to use unsigned long fixed the problem for me.
This bug should be fixed to be more platform independent I suggest.
Kind regards,
Philip