Skip to main content
Associate II
September 5, 2024
Solved

VL53L8CX SPI doesn't work properly

  • September 5, 2024
  • 7 replies
  • 7015 views

Hi everyone: I am working on a project with VL53L8CX Time-of-Flight sensor from Pololu. I integrated it with NUCLEO-H755ZI-Q board over SPI interface based on the example and driver provided in the STMicro en.STSW-IMG040 software package. I configured the SPI3 (MCLK, MISO, and MOSI) on the CN7 to communicate with the sensor. I also have PA4 for SPI3_NSS and PC7 for /PLn signal. The project compiled successfully. However, I believe I am not able to read the registers properly.

 

The firmware reads the "device_id" and "revision_id" from the sensor in the vl53l8cx_is_alive() to determine if the sensor exists. The return values different every time I tried to read. I was able to capture the protocols on the scope, and confirmed the reading values are match with the data shown on the scope. The following scope capture shows the communication:

1. Sending 0x00 to address 0x7fff. The yellow signal is for the MCLK, blue for MOSI, purple for MISO, and green for /CS.

pshih_0-1725544500633.png

2. Receiving 0x0 from address 1 for "revision_id".

pshih_1-1725544500633.png

3. Another reading 0x4 from address 1 for "revision_id".

pshih_2-1725544500633.png

I tried to pull up the MISO signal to 3.3V by 10K resister or pull-down to GND with 47K resister. They don't resolve the issue. Tried different communication baud rate and they don't help. I also tried different module and they seems to have the same issue. At this point, I am not sure if the issue I am facing is in the hardware or software. I am looking forward to hearing your opinion and suggestions. Thanks!

Best answer by John E KVAM

This happened to the ST VL53L8CX Satellite board as well.

Issue : SPI communication is not working when SATEL-VL53L8 (PCB4286A) is connected with flying wires to the NUCLEO-F401RE

Root cause of defection : Supplier populated 2 Level Shifter references for all SATEL-VL53L8 - 1 level shifter reference is incorrect specification. Visual check of the boards is needed to identify Level Shifters references (U4 and U6 component)

  • Faulty ref : NXS0104
  • Good ref :PI4ULS3V204

    4-Bit Automatic Direction Sensing Voltage Translator for Push-Pull /Open Drain

     as per the BOM on st.com

Workaround : None possible – only a replacement of the level shifter will fix the issue.

 

JohnEKVAM_4-1725547204235.png

 

 

 I don't know if it's your exact problem as I've yet to see the Pololu board, but it's a fair guess.

ST is trying to pull back the affected boards, but it's a real mess.

Level shifters are a pain on I2C. I hate those things. I hope this is not your problem; but do check it.

- john

 

 

7 replies

John E KVAM
John E KVAMBest answer
ST Employee
September 5, 2024

This happened to the ST VL53L8CX Satellite board as well.

Issue : SPI communication is not working when SATEL-VL53L8 (PCB4286A) is connected with flying wires to the NUCLEO-F401RE

Root cause of defection : Supplier populated 2 Level Shifter references for all SATEL-VL53L8 - 1 level shifter reference is incorrect specification. Visual check of the boards is needed to identify Level Shifters references (U4 and U6 component)

  • Faulty ref : NXS0104
  • Good ref :PI4ULS3V204

    4-Bit Automatic Direction Sensing Voltage Translator for Push-Pull /Open Drain

     as per the BOM on st.com

Workaround : None possible – only a replacement of the level shifter will fix the issue.

 

JohnEKVAM_4-1725547204235.png

 

 

 I don't know if it's your exact problem as I've yet to see the Pololu board, but it's a fair guess.

ST is trying to pull back the affected boards, but it's a real mess.

Level shifters are a pain on I2C. I hate those things. I hope this is not your problem; but do check it.

- john

 

 

pshihAuthor
Associate II
September 5, 2024

This could be very possible. The VL53L8CX from Pololu using the same level shifter but 8 channels. Thanks your quick info.

Anne BIGOT
Technical Moderator
September 5, 2024

Hello,

Do a visual inspection of your pololu board and check the reference of the level shifter.

The BOM shared on st.com references the right LS Part Number. So if pololu took this BOM it should be OK.

Wrong boards manufactured by ST supplier will be reworked with the right LS.
At the end, reworked boards will be identified with a new part number.

Anyway, a replacement of the faulty board is planned in case of issue.

Regards

 

 

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'
Visitor II
February 17, 2025

Hello,

I am trying to connect the VL53L8CX to the Nucleo -G491RE board using SPI communication

The example and driver provided in the STMicro en.STSW-IMG040 software package provided is for the Nucleo-F401RE, could you let me know what are the step u used to use a diffrent MCU the NUCLEO-H755ZI-Q ?

Thank you in advanced

John E KVAM
ST Employee
February 17, 2025

This sounds like a new topic to me. Feel free to make a new topic. Info gets shared better with short Q and A's instead of making one long thread. 

The folks that did the X-ToF code did an amazing job of handling most of our sensors, but to do it, they had to give up a lot of options - like SPI. So, you can't use that. 

So here is what to do. 

1) build your STM32CubeIDE project without the sensor. But do configure the LPn pin and the SPI and all the others. 

2) Then download the VL53L8API from ST.com and integrate it yourself. Refer frequently to the example code. Steal as much as you can from that example. 

IN the end, you will have the example code running on your MCU.

It's a matter of copying the files across, but if you match the example, it should work out just fine.  

In theory, you could just take the example code, open the .IOC file from STM32CubeIDE and change the processor. But that only works if the MCUs are really close. (There is a warning that it won't work - but it does sometimes.)

Best to just start fresh. Build the MCU project, then copy the files over. 

- john

- john

Anne BIGOT
Technical Moderator
March 13, 2025

Hello

The issue we have with SPI is linked to the VCC(B) values.
SATEL boards need to have a 1.2V or 1.8V voltage. This is not covered by the NXS0104 and NXS0108 LDOs

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'
Visitor II
March 13, 2025

Is there any SPI code for circuitpython that works for VL53L8CX ?

If not fully functional, at least to test the SPI interface to ensure it's work.

If there's a full version that that be used for ranging 4x4 or 8x8, that would be perfect. Please kindly share.

 

Thanks,

Jeff

Anne BIGOT
Technical Moderator
March 17, 2025

Hello

There can be some issues...

Better would be to order the latest SATEL-VL53L8 from ST site.

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'
Visitor II
March 17, 2025

That's not good. I've bought 8 of these from Pololu.

kwc
Associate II
March 21, 2025

Hi, this is Kevin from Pololu. I can confirm that our VL53L8CX carrier does work with SPI. We have tested it with multiple controllers, including an ST Nucleo-F411RE running the CubeIDE_F401RE_Example_SPI code from the ULD API (STSW-IMG040):

irs19b-nucleo-f411re.jpg

We generally recommend keeping the wires as short as possible, but I specifically used longer ones here (12 inches) to demonstrate that it still works.

Our carrier board is intended to let people use the sensor with 3.3V and 5V controllers, and it was never intended to work at lower voltages.