Skip to main content
Associate
November 2, 2023
Solved

Unable to start ranging on the vl53l8cx

  • November 2, 2023
  • 3 replies
  • 2369 views

Hello,

I've already used the vl53l5cx and it worked flawlessly, so I decided to try the newest one. I'm working on an esp32s3 and a satel-vl53l8 using the ULD. I completed the platform file, and it initialized the sensor without errors. But when the sensor tries to start ranging, I get an VL53L8CX_STATUS_ERROR caused by two data sizes which should be the same but aren't.

//In vl53l8cx_api.c 
//vl53l8cx_start_ranging()

if(tmp != p_dev->data_read_size)
{
	status |= VL53L8CX_STATUS_ERROR;
}

I can’t figure out how to fix it. If you need any additional information, I will be pleased to answer.

Thanks

This topic has been closed for replies.
Best answer by RJRP

Thank you for your answers,

I discovered, after a lot of debugging, that the faulty function was the default implementation of SwapBuffer.

Here's my new implementation, if it helps anyone :

void SwapBuffer(uint8_t *buffer, uint16_t size) {
 uint32_t i;
 uint8_t tmp[4] = {0};

 for (i = 0; i < size; i = i + 4) {

 tmp[0] = buffer[i + 3];
 tmp[1] = buffer[i + 2];
 tmp[2] = buffer[i + 1];
 tmp[3] = buffer[i];

 memcpy(&(buffer[i]), tmp, 4);
 }
}

And esp32s3's i2c supports these amount of data without any problem.

Have a nice day

Romain

3 replies

Anne BIGOT
Technical Moderator
November 9, 2023

Hello,

The VL53L5CX and the VL53L8CX are not pin to pin comptible.

Did you modify your project regarding this change ?

Anne

Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised. ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'
AlexCloned
Senior
November 9, 2023

Assuming that if you're using the Satel-Vl53l8 development board, you shouldn't have PCB layout errors, as it's already proven by your successful initialization. This leads us to believe that the read data does not match the expected quantity or there is some kind of misalignment.

What is the maximum data transfer size that your peripheral supports? When you programmed the WrMulti() function on your platform, did you consider that transfers might be longer than what the peripheral (assuming you're using I2C) supports? The same goes for byte alignment issues. It would be interesting to debug and see how much the difference is between tmp and p_dev->data_read_size. A clue might come from there if you haven't discovered it yet. Good luck. Alex.

RJRPAuthorBest answer
Associate
November 11, 2023

Thank you for your answers,

I discovered, after a lot of debugging, that the faulty function was the default implementation of SwapBuffer.

Here's my new implementation, if it helps anyone :

void SwapBuffer(uint8_t *buffer, uint16_t size) {
 uint32_t i;
 uint8_t tmp[4] = {0};

 for (i = 0; i < size; i = i + 4) {

 tmp[0] = buffer[i + 3];
 tmp[1] = buffer[i + 2];
 tmp[2] = buffer[i + 1];
 tmp[3] = buffer[i];

 memcpy(&(buffer[i]), tmp, 4);
 }
}

And esp32s3's i2c supports these amount of data without any problem.

Have a nice day

Romain