2024-07-15 02:24 AM
I was using the sensor until now on an Raspberry Pi with direct access to the I2C bus without problems.
Now I use an FT260 USB-I2C interface to communicate to the sensor from a PC via USB. In principle the communication is working, e.g. vl53l5cx_is_alive() works as expected.
But the initialization fails. On the poll for sensor booted status I now always get a 9 as the answer instead of the expected 1 until the timeout is reached.
In the documentation I haven't found any hint what the value of 9 at this point means.
This is the place where vl53l5cx_init() fails:
/* Wait for sensor booted (several ms required to get sensor ready ) */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= _vl53l5cx_poll_for_answer(p_dev, 1, 0, 0x06, 0xff, 1);
if(status != (uint8_t)0){
printf("vl53l5cx_init(): Wait for sensor booted failed\n");
goto exit;
}
And inside _vl53l5cx_poll_for_answer() I see that the returned value is 9. Because the expected value is 1 _vl53l5cx_poll_for_answer() fails.
Any idea?
2024-07-15 08:00 AM
Just prior to that query is an I2C transfer of 0x8000 and not all MCU's can handle it. The trick is to see if there is a limitation on your I2C maximum length, and if so, write the I2C data in smaller 'chunks'. I know others have had this issue and solutions exist for lots of MCU's.
I seem to remember one on this forum. So if you do have a limitation, google for a solution. You will find one.
- john
2024-07-15 12:52 PM
If your problem is at I2C long-write issue, try adapting this code to your device.
One example of how someone solved this problem for an Arduino platform is here:
VL53L5CX/src/platform.cpp at main · stm32duino/VL53L5CX · GitHub
have a look and take the while loop out of the uint8_t VL53L5CX::WrMulti() function.
- john