2021-11-25 01:18 AM
Hello,
the VL53L5CX is a really nice senor. I have done some measurements using the Windows GUI and was impressed, so I wanted to write a driver for the sensor and do some further evaluation.
I then tried to initialize the sensor using the ULD-API and my Nucleo-Board, but the sensor is not detected via I²C, I double checked with the Windows GUI - everything works just fine - so the Hardware should be alright.
I tried using the provided example in the API - same problem. I did not do anything fancy yet, are there some known issues? What is the Firmware in the Windows GUI doing different than the API? The init() loads the default firmware to the sensor, how long does that take?
Background:
What else could go wrong?
Thank You for Your help!
Kind regards,
Niklas
2021-12-06 07:27 AM
I'm betting Byte-swap or word-swap issues. That would explain why your Chip ID was wrong and why you get unintelligible data.
the code works on an ARM processor. Does your MCU have the same endianness?
int32_t vl53l5_dci_swap_buffer_byte_ordering() is the function that does the work.
Find that and work backwards to see what is going on.
2021-12-07 03:26 AM
The STM32F401 and the STM32L476 are both little endian. The function you mentioned is not included in the API, there is a SwapBuffer in platform.h, and vl53l5cx_dci_read_data, vl53l5cx_dci_write_data, and vl53l5cx_dci_replace_data in the api.
I changed the byte order, which resulted in the sensor not initializing, because the endianess should have been wrong when reversing the byte order, since the F401 and the L476 have the same endianess.
Changing the byte order would also not affect the value of the target status, which is a uint8_t.