cancel
Showing results for 
Search instead for 
Did you mean: 

API timeout in VL53L0X_get_info_from_device()

mrosing
Associate II
Posted on October 27, 2016 at 03:57

I have modified the platform.h and platform.c to run on Raspberry Pi.  The i2c-tools show I can read the device, and the routine VL53L0X_DataInit() returns no error, so I can write to the device.  But I am getting a timeout error from the VL53L0X_get_info_from_device() routine. 

Is there any place where a complete list of internal registers and what they do for the VL53L0X device exist?  The API seems really complicated for just having to flip a few bits on the I2C bus.

Thanks!

Mike

#vl53l0x
4 REPLIES 4
mrosing
Associate II
Posted on October 27, 2016 at 22:54

I have chased it down to something called ''strobe''.  It writes a zero to register 0x83 and expects non-zero back.  Then when it gets non-zero back it writes a 1.  I have no idea what this register is, nor what it is supposed to do, but it obviously isn't doing what it is supposed to do. 

You can see this in file vl53l0x_api_core.c, function VL53L0X_device_read_strobe().

Hmmm.... I guess it writes a 1 no matter if it times out or not.  The main question is why is it timing out?

mrosing
Associate II
Posted on October 28, 2016 at 16:07

OK, so my actual problem was the WrByte() routine was not actually sending data correctly over the i2c.  Now it does, and I am past this problem and onto a ranging error.  But at least the device is no longer hanging.

And a word to ST: please publish a register map!!!

mrosing
Associate II
Posted on October 30, 2016 at 01:00

I have 5 units I can plug into my Pi. 3 of them gave floating point errors, and 2 of them give the range fault error. I decided to chase down the floating point error and found a divide by zero in routine calc_macro_period_ps() because 0 was sent in as a parameter. By reordering the initialization values to occur before VL53L0X_perform_ref_spad_management() (and by setting

uint8_t vcselPulsePeriodPCLK = 14;
FixPoint1616_t seqTimeoutMilliSecs = 5;

instead of having no value, the 3 units which had floating point errors are now actually reading back range data. Now, all I have to do is find a way to fix the broken units by writing over their default internal values and they might do something useful as well. This is still frustrating though because I have no idea what the correct values for ANYTHING should be, nor why they should be that way. Mike
mrosing
Associate II
Posted on October 30, 2016 at 03:30

This is good, I finally got the units which were failing with a ''range error'' to work. What I did was modify the StaticInit to always perform the VL53L0X_perform_ref_spad_management() routine. I now have the continuous example code running on the Raspberry Pi and I just need to remove all my printf's so the API becomes a horrible but useful library for the rest of my demo system.

I'd really like to know what this part is doing and why so I can make better use of it. But for the moment at least I can put it to work for what I need. What a pain in the *** though!!! Mike Change to StaticInit to make modules work:

VL53L0X_Error VL53L0X_StaticInit(VL53L0X_DEV Dev)
{
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
VL53L0X_DeviceParameters_t CurrentParameters = {0};
uint8_t *pTuningSettingBuffer;
uint16_t tempword = 0;
uint8_t tempbyte = 0;
uint8_t UseInternalTuningSettings = 0;
uint32_t count = 0;
uint8_t isApertureSpads = 0;
uint32_t refSpadCount = 0;
uint8_t ApertureSpads = 0;
uint8_t vcselPulsePeriodPCLK = 14;
FixPoint1616_t seqTimeoutMilliSecs = 5;
LOG_FUNCTION_START('''');
Status = VL53L0X_get_info_from_device(Dev, 1);
/* set the ref spad from NVM */
/* Store pre-range vcsel period */
if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_GetVcselPulsePeriod(
Dev,
VL53L0X_VCSEL_PERIOD_PRE_RANGE,
&vcselPulsePeriodPCLK);
}
if (Status == VL53L0X_ERROR_NONE) {
VL53L0X_SETDEVICESPECIFICPARAMETER(
Dev,
PreRangeVcselPulsePeriod,
vcselPulsePeriodPCLK);
}
/* Store final-range vcsel period */
if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_GetVcselPulsePeriod(
Dev,
VL53L0X_VCSEL_PERIOD_FINAL_RANGE,
&vcselPulsePeriodPCLK);
}
if (Status == VL53L0X_ERROR_NONE) {
VL53L0X_SETDEVICESPECIFICPARAMETER(
Dev,
FinalRangeVcselPulsePeriod,
vcselPulsePeriodPCLK);
}
/* Store pre-range timeout */
if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_GetSequenceStepTimeout(
Dev,
VL53L0X_SEQUENCESTEP_PRE_RANGE,
&seqTimeoutMilliSecs);
}
if (Status == VL53L0X_ERROR_NONE) {
VL53L0X_SETDEVICESPECIFICPARAMETER(
Dev,
PreRangeTimeoutMicroSecs,
seqTimeoutMilliSecs);
}
/* Store final-range timeout */
if (Status == VL53L0X_ERROR_NONE) {
Status = VL53L0X_GetSequenceStepTimeout(
Dev,
VL53L0X_SEQUENCESTEP_FINAL_RANGE,
&seqTimeoutMilliSecs);
}
if (Status == VL53L0X_ERROR_NONE) {
VL53L0X_SETDEVICESPECIFICPARAMETER(
Dev,
FinalRangeTimeoutMicroSecs,
seqTimeoutMilliSecs);
}
count = (uint32_t)VL53L0X_GETDEVICESPECIFICPARAMETER(Dev,
ReferenceSpadCount);
ApertureSpads = VL53L0X_GETDEVICESPECIFICPARAMETER(Dev,
ReferenceSpadType);
printf(''count = %d, ApertureSpads = %x
'', count, ApertureSpads);
/* NVM value invalid */
/* if ((ApertureSpads > 1) ||
((ApertureSpads == 1) && (count > 32)) ||
((ApertureSpads == 0) && (count > 12)))
{*/
printf(''calling VL53L0X_perform_ref_spad_management
'');
Status = VL53L0X_perform_ref_spad_management(Dev, &refSpadCount,
&isApertureSpads);
/* }
else
{
printf(''calling VL53L0X_set_reference_spads
'');
Status = VL53L0X_set_reference_spads(Dev, count, ApertureSpads);
}*/
printf(''Static Init: after spads
'');