cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to initialize and as there is no register map I am stuck with this

Rituraj
Senior

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

8 REPLIES 8
John E KVAM
ST Employee

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:

printf("Sensor initializing, please wait few seconds\n");
    status = vl53l8cx_init(&Dev);
    status = vl53l8cx_set_ranging_frequency_hz(&Dev, 2);                // Set 2Hz ranging frequency
    status = vl53l8cx_set_ranging_mode(&Dev, VL53L8CX_RANGING_MODE_CONTINUOUS);  // Set mode continuous
if you get a status failure here, we can work what the issue might be. 
 
But frankly if you get this far, I'm guessing the rest will work.
- 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.

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

IMG_20240619_155752530.jpgIMG_20240619_155730654.jpgIMG_20240619_155742521.jpg

Rituraj
Senior

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

John E KVAM
ST Employee

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

 

 


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.
Rituraj
Senior

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 .

Rituraj_0-1718950156684.png

Kindly guide me how I can remove this warning and get things done.

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 

Rituraj
Senior

I tried using vl53l5cx with stm32f407G  and followed the document UM2974 . The initialization failed again with this output on HTERM

 

Rituraj_0-1719211687071.png

 

What should I do to get it started?

 

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

 


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.