Skip to main content
RSzil
Associate
January 29, 2019
Solved

VL53L1X RangeStatus No Update problem

  • January 29, 2019
  • 2 replies
  • 1240 views

Hi!

I want use an VL53L1X sensor for our project. I "ported" to original ST api to TI chip and TIRTOS. But I cant measure any distance. Now I just want to try the sensor, so I using "polling" method. But when I call a GetMeasurementDataReady function, the "data_ready" variable not set. I am almost sure not problem with porting, because I can get the device Info. After I call GetDeviceInfo the struct has contains:

name : Vl53L1 cut 1.1

type: VL53L1

product ID: 00000

ProductType: 239 (0xef)

RevMajor: 1

RevMinot: 15 (0x0f)

The drivers info is here:

revision 1885

major 2

minor 3

build 3

My code is here:

 VL53L1_Error status;
 VL53L1_RangingMeasurementData_t ranging;
 // dev=&pdev;
 
 uint8_t data_ready = 0;
 
 init_i2c();
 // dev.I2cDevAddr=0x52;
 dev.I2cDevAddr = 0x29;
 
 PIN_setOutputValue(ledPinHandle, SENSOR_SHUTDOWN, SENSOR_OFF);
 Task_sleep(100000);
 PIN_setOutputValue(ledPinHandle, SENSOR_SHUTDOWN, SENSOR_ON);
 Task_sleep(100000);
 
 status = VL53L1_WaitDeviceBooted(&dev);
 //Task_sleep(10000);
 
 status = VL53L1_DataInit(Dev);
 status = VL53L1_StaticInit(Dev);
 // status = VL53L1_SetPresetMode(Dev, VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS);
 // status = VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_SHORT);
 // status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 20000);
 // status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 25);
 // status= VL53L1_set_interrupt_polarity(Dev, interrupt_polarity);
 // status=VL53L1_SetUserROI(Dev, &roiData);
 
 status = VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
 status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 50000);
 status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev, 500);
 status = VL53L1_StartMeasurement(Dev);
 while (1)
 {
 
 
 
 while (!data_ready)
 {
 Task_sleep(1000);
 status = VL53L1_GetMeasurementDataReady(&dev, &data_ready);
 Log_info0("wait for data"); //<---- STUCK HERE
 if (status != 0)
 {
 while (1)
 {
 
 }
 }
 }

I digging down to code, I measure the I2C lines. The API read the 0x0031 register, and read 0x03. When API call the mask check function, this readed data should 0x01, when new data is ready.

Any suggestion any changes? All of the status has return 0, so the API I think is working.

Where can I start the debug?

Thanks for answer!

Best regards,

Richard

This topic has been closed for replies.
Best answer by John E KVAM

It's most likely still a porting issue. Your reads only access bytes, but you also need words and long words. insert the enclosed code into your main.c. It tests all combinations of IO. I'm guessing there is a byte-swap somewhere.

All that code looks good - including the commented out bits.

2 replies

John E KVAM
John E KVAMBest answer
ST Employee
April 8, 2019

It's most likely still a porting issue. Your reads only access bytes, but you also need words and long words. insert the enclosed code into your main.c. It tests all combinations of IO. I'm guessing there is a byte-swap somewhere.

All that code looks good - including the commented out bits.

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
RSzil
RSzilAuthor
Associate
April 9, 2019

Hy John!

Thanks for your answer, but this project is over. In the past I figured out some length calculation was wrong, but thanks for the test code.

regards,

Richard