cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L8 api init function didin't work, needed additional delay

DBonh.1
Associate III

Hi, I'm hosting a VL53L8CX with a STM32F4, 48-pin instead of the 64-pin on your eval board. There's a 5" flex cable between processor and L8. The vl53l8cx_init() function was failing. Slowing the SPI baud didn't help. Increasing wait time on line 276 of the api file didn't help. The thing that fixed it was inserting a brief delay at line 274 of the api file, which was slightly before you have a delay. Source code snippet below shows my delay.

BTW, I noticed that the .ioc file that came with your ULD has the SPI bus disabled. Did you do some custom monkeying with the HAL SPI driver? I'm using the .ioc and HAL driver, as is, with my application. And it works, as long as I add the delay described here.

 

status |= VL53L8CX_WrByte(&(p_dev->platform), 0x000F, 0x43);

status |= VL53L8CX_WaitMs(&(p_dev->platform), 1);

status |= VL53L8CX_WrByte(&(p_dev->platform), 0x000F, 0x40);

HAL_Delay(5); //FDT NOV 2024: NEEDS A 1+MS DELAY HERE OR IT WILL WORK THE FIRST TIME BUT NOT AFTER CYCLING POWER.

status |= VL53L8CX_WrByte(&(p_dev->platform), 0x000A, 0x01);

status |= VL53L8CX_WaitMs(&(p_dev->platform), 100);//FDT NOV 2024: DOESN'T HELP TO MAKE THIS 500. NEEDS DELAY ABOVE.

/* Wait for sensor booted (several ms required to get sensor ready ) */

2 REPLIES 2
John E KVAM
ST Employee

It's our claim that the SPI works. At one time, there was an issue with SLOW SPI configurations, but that was fixed in Version 1.2. (Version 2.0 is what is currently available on the website.)

It was however pointed out that speed over 3M was an issue.

Could you be using an SPI greater than 3M?

- john


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.

My SPI clock looked like the same speed on the scope as it did with your driver. And my SPI config setting look the same (pasted below). And I tried slowing it down by a factor of 8 (SPI_BAUDRATEPRESCALER_256 from _32) without fixing it. Same crystal and clock configs in both cases.
My first thought was that my 5" flex cable between controller and ToF created a sketchy edge condition in hardware, but a project that used your .ioc with disabled SPI bus ran fine, but my .ioc-created HAL SPI bus failed, both running on the same board with the same flex cable. The failures were entirely repeatable. Mine would run fine if I ran your files first without cycling power. But when I cycled power and tried to run mine, it failed. Does the ToF boot run a little slower after cycling power?
I didn't yet do a full file compare between your SPI driver files and the ones created by my .ioc, but there might be a tiny diff in there somewhere. It's a curious problem. I got it working so I need to move forward without investigating further. But surely someone else is going to stumble on this. If your peeps want to dig in I could send my Cube projects, the one that works and the one that doesn't.