cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L0X timeout for unlock register 0x83

BHakes
Associate II

Hello!

I'm hoping to understand what might cause a timeout on register 0x83. I understand 0x83 is a lock/unlock style register. During configuration, we run VL53L0X_get_info_from_device(Dev, 1) function to get SPAD information. This function appears to call another function called VL53L0X_device_read_strobe(VL53L0X_DEV Dev). The read strobe function tries to write 0x00 data to 0x83 register, then enters a timed polling loop, waiting until 0x83 register reflects 0x00 data. The function may time out if 0x83 register never reports 0x00 data.

 

My question is why can 0x83 register time out?

I don't think we have ever seen this behavior in years of use of the sensor. If we create a custom implementation of the API, is it necessary to be checking this 0x83 register to see writes go through? Why aren't other registers checked after writes?

If a sensor is experiencing this time out, what other behavior might be impacted? Does I2C communication still function?

Any help on the above questions would be much appreciated!

 

3 REPLIES 3
Bin
ST Employee

Hi:

Register `0x83`,This is a stroke/handshake/read gate register in the internal NVM/info read process. Not a regular ranging service register. In other words, the purpose of checking `0x83` here is to confirm that the device has completed the corresponding internal operation and is ready for the next step.

So, when a timeout happens on `0x83`, it usually means that the software is waiting for an **internal state transition** that did not occur within the expected time. This is why the code uses a timeout: without it, the polling loop could wait forever if the internal handshake never completes.

 
VL53L0X_Error VL53L0X_device_read_strobe(VL53L0X_DEV Dev)
{
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
uint8_t strobe;
uint32_t LoopNb;
 
LOG_FUNCTION_START("");
 
Status |= VL53L0X_WrByte(Dev, 0x83, 0x00);
 
/* polling
* use timeout to avoid deadlock
*/
if (Status == VL53L0X_ERROR_NONE) {
LoopNb = 0;
do {
Status = VL53L0X_RdByte(Dev, 0x83, &strobe);
if ((strobe != 0x00) || Status != VL53L0X_ERROR_NONE)
break;
 
LoopNb = LoopNb + 1;
} while (LoopNb < VL53L0X_DEFAULT_MAX_LOOP);
 
if (LoopNb >= VL53L0X_DEFAULT_MAX_LOOP)
Status = VL53L0X_ERROR_TIME_OUT;
}
 
Status |= VL53L0X_WrByte(Dev, 0x83, 0x01);
 
LOG_FUNCTION_END(Status);
return Status;
 
}

The timeout (VL53L0X_DEFAULT_MAX_LOOP) is used because `VL53L0X_device_read_strobe()` is polling register `0x83` and waiting for the device to signal completion of an internal read-handshake sequence.

In this flow, `0x83` is not used like a normal configuration register. It acts as a synchronization or strobe register for internal device information access. After writing `0x83 = 0x00`, the code waits until the device changes it to a non-zero value, which indicates that the internal operation has completed.

If, for any reason, that internal state transition never happens, the polling loop would otherwise run forever. The timeout is therefore necessary to prevent the firmware from getting stuck in an infinite wait condition and to allow the API to return an error instead.

 

Best Regards,

Bin FAN


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.
BHakes
Associate II

Hi Bin,

Thank you for the information! 

We have added this check in our implementation. We are now considering how to handle a timeout if it does occur. Without understanding what might cause a timeout, it's difficult for us to appropriately handle the failure mode. If you could please answer the following it would be very helpful.

1. If a timeout occurs, would it be appropriate to reset the VL53L0X and try initialization again? 

2. Does a timeout indicate an irrecoverable sensor?

3. Are timeouts something we should expect to happen more frequently as sensors age?

4. If a timeout has happened should we expect impacts to other functionality such as I2C communication to the VL53L0X?

Bin
ST Employee

Hi:

Thank you for your follow-up questions.

Under normal operating conditions, a timeout won't happen.

If a timeout is observed, it indicates that the expected internal process did not complete within the allowed time. To be honest, we have not encountered this situation before, so we cannot provide specific opinions. sorry for that.

Best Regards,

Bin FAN


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.
Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.