cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L0X_GetInterruptMaskStatus fails

MMeng.3
Associate II

We are trying to get a VL53L0X sensor to run but VL53L0X_GetInterruptMaskStatus() constantly fails and we cant perform any measurements.

We compiled the API provided by ST provided from https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html#tools-software into a DLL. Basic communication is working, i.e. we can read regs 0xC0 and 0xC1 and they return the expected 0xEE and 0xAA. Running dataInit() and staticInit() works without issues.

However once we get to calibration or actual range measurements, the sensor throws a 

VL53L0X_ERROR_RANGE_ERROR or -6 during the calibrations, i.e. VL53L0X_PerformRefSpadManagement() and VL53L0X_PerformRefCalibration(). This is caused by the VL53L0X_GetInterruptMaskStatus() function where apparently two bits are set which the API doesn't like. Reading the VL53L0X_REG_RESULT_INTERRUPT_STATUS constantly returns 0x54. This seems to be the same behaviour as described in https://community.st.com/s/question/0D50X00009XkXPeSAN/vl53l0x-inialisation-failing-in-perfomrefspadmanagment. As suggested, we ignored the errors in calibration and set the configuration.

Once we get to VL53L0X_GetMeasurementDataReady() when reading a measurement, the interrupt status is polled again an again fails as the byte returned is 0x54.

We have to sensors and both return the same results. Did anyone encounter the same error and know howto fix it?

            int vl_error = 0;
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_DataInit_devless();
            }
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_StaticInit_devless();
            }
 
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_PerformRefCalibration_devless();
                vl_error = 0;
            }
 
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_PerformRefSpadManagement_devless(mRefSpadCnt, isApertureSpads);
                vl_error = 0;
            }
            
            
 
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_SetDeviceMode_devless();
            }
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_SetConfig_devless();
            }
 
 
 
            Thread.Sleep(50);
 
            if (vl_error == 0)
            {
                vl_error |= VL53L0X.VL53L0X_PerformSingleRangingMeasurement_devless();
            }

The _devless functions are just wrappers around the same function from the API where we instantiate a global VL53L0X_Dev_t myDev; and use &myDev in the function calls to the API.

We tried various configs as provided in the example applications from the API folder but all produce the same result. The config function look like this

VL53L0X_Error VL53L0X_SetConfig_devless()
{
	VL53L0X_Error Status = VL53L0X_ERROR_NONE;
 
    // Enable/Disable Sigma and Signal check
    if (Status == VL53L0X_ERROR_NONE) {
        Status = VL53L0X_SetLimitCheckEnable(&myDev,
            VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, 1);
    }
    if (Status == VL53L0X_ERROR_NONE) {
        Status = VL53L0X_SetLimitCheckEnable(&myDev,
            VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, 1);
    }
 
    if (Status == VL53L0X_ERROR_NONE) {
        Status = VL53L0X_SetLimitCheckEnable(&myDev,
            VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD, 1);
    }
 
    if (Status == VL53L0X_ERROR_NONE) {
        Status = VL53L0X_SetLimitCheckValue(&myDev,
            VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD,
            (FixPoint1616_t)(1.5 * 0.023 * 65536));
    }
 
    return Status;
}

The only difference we noticed, is when we used the long range settings where the following calls are made:

if (Status == VL53L0_ERROR_NONE) {
Status = VL53L0_SetVcselPulsePeriod(pMyDevice, 
VL53L0_VCSEL_PERIOD_PRE_RANGE, 18);
}
if (Status == VL53L0_ERROR_NONE) {
Status = VL53L0_SetVcselPulsePeriod(pMyDevice, 
VL53L0_VCSEL_PERIOD_FINAL_RANGE, 14);
}

Whenever I set these SetVcselPulsePeriod settings, the VL53L0X_PerformSingleRangingMeasurement() now exits without error but the range status is '2', indicating a signal fail (the range is 8191mm which seems to be used as an error code).

1 REPLY 1
John E KVAM
ST Employee

On gets the 8191 (Range status 2) when there is no target within range. I'm thinking it would work if you pointed the sensor at a target within a meter or so.

The failure of the RefSpad calibration is a problem that will not die. Some sensors, when re-flowed onto the board change so much that the programed refSpad cannot do the fine adjust you are asking it to do.

When this happens, try programming the refSpad to 3 and re-running the calibration.

We fixed this code in the later releases, but many sites have derived code from prior releases.

And the problem only occurs on some sensors - but apparently is happening on your.

  • joohn

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question. It helps the next guy.