2024-08-02 03:51 PM
To begin, I am using the vl53l8cx breakout board from Pololu with a Nucleo-F446RE and PlatformIO. I have been having trouble getting the VL53L8CX to start ranging using the SPI2 interface. I get successful responses from the `_is_alive()` and `_init()` methods, but find that I get an error status of 1 from the call to `vl53l8cx_dci_read_data()` within the `_start_ranging()` method. Subsequently, a few lines down, `_start_ranging()` errors out with VL53L8CX_STATUS_ERROR.
I tried following @RJRP 's solution here, but it didn't solve my problem.
I have jumper wires from the Nucleo-F446RE to a breadboard. The wires are possibly too long, ~12cm in length.
For clarity, the lines in question:
/* Read ui range data content and compare if data size is the correct one */
// This gives status = 1
status |= vl53l8cx_dci_read_data(p_dev, (uint8_t*)p_dev->temp_buffer, 0x5440, 12);
// This gives status = 255
(void)memcpy(&tmp, &(p_dev->temp_buffer[0x8]), sizeof(tmp));
if(tmp != p_dev->data_read_size)
{
status |= VL53L8CX_STATUS_ERROR;
}
I have enabled most of the macros in `platform.h` to reduce the size of the information (I left NB_TARGET_DETECTED, DISTANCE_MM, and TARGET_STATUS as active). My SPI baud rate is 1.3125 Mb/s, and I have properly configured CPOL = 1 and CPHA = 1. For further information/configuration setup, here is the link to my project repository: https://github.com/lukestroh/nucleo-f446re-vl53l8cx-spi-platformio
Solved! Go to Solution.
2024-08-06 04:25 PM
I had one customer claim that his power supply was a touch marginal. When the sensor started, it drew more power and things went south.
Perhaps you could put a scope on the power input and see if it drops about the time you start the sensor.
That might explain how you can communicate just fine - until you issue the start command.
On that Pololu board, you might also just put a scope on the 3v3out pin and see what you get.
Unfortunately, this is just a guess. But I think it's worth a test.
- john
2024-08-06 04:04 PM
Two things to try... Shorten your SPI wires and try a different speed.
The init is a large write, and there are firmware handshakes. I find it odd that you got through so much only to fail. You must be pretty close.
I'm betting a shorter wire will do it.
After that we can try better wires, twisted pair and some other techniques to get your length back.
- john
2024-08-06 04:25 PM
I had one customer claim that his power supply was a touch marginal. When the sensor started, it drew more power and things went south.
Perhaps you could put a scope on the power input and see if it drops about the time you start the sensor.
That might explain how you can communicate just fine - until you issue the start command.
On that Pololu board, you might also just put a scope on the 3v3out pin and see what you get.
Unfortunately, this is just a guess. But I think it's worth a test.
- john
2024-08-08 03:36 PM
Thanks @John E KVAM, I scoped the 3.3V output and you're right, it was pulling down. I fixed the power supply and everything is working, I appreciate the insights.