2024-06-13 05:03 AM
I am working with a vl53l8cx and following the instructions exactly to initialize the sensor but it always generates a hard fault error. I tried debugging , the hard fault is generated once the function Wrbyte is being called and it writes to the address 0x0777. As no register map probably exist I am stuck with this . Need Help
2024-06-17 12:18 PM
Rituraj -
ST wrote the code for you. In theory you would download the code - along with a lot of examples - and start from there. (If you were not using an ST MCU, you would have to adapt the platform.c program to work with your MCU.
There are a few common failures that I see:
1) people don't realize the Sensor's registers are 16 bits long. (Looks like that is NOT your issue)
2) Byte-swap or word-swap. This one can be a real pain.
3) Inability of your MCU to write those 0x8000 byte long messages.
I don't know of a 0x777 register. Maybe there is one, but it's not used by any of our code.
But start with the ST code. The first 3 calls are:
2024-06-19 03:36 AM
Hello John,
Thank you for your response.
I am not really sure why I am unable to get it done . As it can be seen in the attached images . as soon as I try to intialize TOF by using the function vl53l8cx_init(); function a hard fault error is generated . as soon as the first command is used to write on register 0x7fff. the hardfault is generated. Kindly share if there is a document or a tutorial to use this sensor with either stm32wb series or stm32f429zit
2024-06-19 03:57 AM
I have also attached the report from cubemx for better understandinhttps://drive.google.com/file/d/1neESVR9HI_-cw9ZjaNKdmIHFJvBYsmFK/view g as there might be some other issue
2024-06-20 08:40 AM
The register is not the issue. It's the I2C plumbing itself. Your first access to the i2C is failing. So:
What happened when you called i2C init?
I see from your project that you have I2C Clock Speed (Hz) 100000
A minimum effective setting for the i2C should be 400,000. (1,000,000 is better.)
Could it be that your eval board was set up for SPI? There are 3 jumpers on the board. Two are one way, and the third is backward.
I'm going to guess that this is either a failure in the configuration of XCube or a hardware issue.
(Did you get any little yellow warning triangles on any of the XCube screens?)
- john
2024-06-20 11:08 PM
Hello John,
Thank you for your response . You are right I missed the frequency part but I have corrected it now . I am getting a warning in MX cube .
Kindly guide me how I can remove this warning and get things done.
2024-06-21 02:10 AM - edited 2024-06-21 02:12 AM
I also tried to work with Vl53L5cx so that the confusion of SPI and I2c wouldn't cause issue . I am running I2c in fast mode with 400000 . I have no warning inside MX cube or cube ide for this one but it still gets hard fault error in the same way.
Here is the report associated with this
https://drive.google.com/file/d/1s4osjup-QBwRrN3jbbDILhed0oHqDv5n/view?usp=drive_link
2024-06-23 11:46 PM
I tried using vl53l5cx with stm32f407G and followed the document UM2974 . The initialization failed again with this output on HTERM
What should I do to get it started?
2024-06-24 08:58 AM
That yellow warning is the key. Something is still not installed right. And unfortunately, I don't know what is wrong.
My experience says that until all the warnings go away, the CubeMX software will not run.
Your error message is telling you that the MCU cannot connect with the sensor. It's guessing that you are not trying to connect with the main sensor, but you are.
One of your i2C lines, your interrupt line or the reset pins are not fully configured in your project.
- john