2024-10-07 04:30 AM
I am trying to use VL53L8CX with stm32f4 discovery but had no success. Implementing the preexisitting API has been tough. Is there a register map for this sensor whcih can be used to create a minimalistic driver and interface sensor using I2C or SPI.
If anyobne knows what is register 0x7FFF . Please let me know.
Solved! Go to Solution.
2024-10-07 07:33 AM
The VL53L8CX actually has an MCU in it, and that 80K of code you write to it to start the sensor is the Firmware running in that sensor.
As such a 'register map' would more reasonably be called an interface protocol. But we do communicate over the i2C using addresses - and for all the world it's a register map. But a pretty complex one.
There are a couple of ways you can hook up that stm32f4 discovery. If you are using the VL53L8-satel, you might be having a known issue with the SPI (Our supply stuffed the wrong level shifter.)
Solved: VL53L8CX SPI doesn't work properly - STMicroelectronics Community
Check your board for the wrong part.
It was also noted that if you run the SPI too slowly it has an issue. 3Mbits seems to work just fine.
But you should be able to get the sensor running with the I2C.
The startup code downloads some 80K and we have to change pages to get it all downloaded. That's register 0x7fff.
When running all the communication is done on the same page.
If using a non-ST MCU sometimes the I2C cannot make those large I2C transfers, and one has to break them into smaller chunks. (This is not your issue, but it happens to others. )
Don't give up on the APi so quickly please. Running this beast with a register map can be done, but it took us years. And you would end up hating ST. The API is validated and well tested. It has lots of advantages.
- john
2024-10-07 07:33 AM
The VL53L8CX actually has an MCU in it, and that 80K of code you write to it to start the sensor is the Firmware running in that sensor.
As such a 'register map' would more reasonably be called an interface protocol. But we do communicate over the i2C using addresses - and for all the world it's a register map. But a pretty complex one.
There are a couple of ways you can hook up that stm32f4 discovery. If you are using the VL53L8-satel, you might be having a known issue with the SPI (Our supply stuffed the wrong level shifter.)
Solved: VL53L8CX SPI doesn't work properly - STMicroelectronics Community
Check your board for the wrong part.
It was also noted that if you run the SPI too slowly it has an issue. 3Mbits seems to work just fine.
But you should be able to get the sensor running with the I2C.
The startup code downloads some 80K and we have to change pages to get it all downloaded. That's register 0x7fff.
When running all the communication is done on the same page.
If using a non-ST MCU sometimes the I2C cannot make those large I2C transfers, and one has to break them into smaller chunks. (This is not your issue, but it happens to others. )
Don't give up on the APi so quickly please. Running this beast with a register map can be done, but it took us years. And you would end up hating ST. The API is validated and well tested. It has lots of advantages.
- john
2024-10-07 09:42 PM
Hello John,
I Thank you for your response. I just checked the evaluation board I own , The level shifters(PI4ULS3V204) are fine .
I am not using SPI so as per your response on another query this must be a misconfigured I2C . I have already gone through most of documentations UM3109 , UM3108 , AN5945. Can you tell me what should be the configuration of I2C ?
This is what I have done, What could be wrong here.
I also tried another and TOF configuration for it is here
Please let me know what needs to be changed
2024-10-08 10:20 AM
When you generate the code, do you get:
/**
* @brief I2C1 Initialization Function
* @PAram None
* @retval None
*/
static void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 1000000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
}
This is what works for me.
I don't have a discovery board, but I know that processor has more than one I2C. You need a schematic to verify that you have chosen the correct I2C pins. Make sure it's I2C1.
(And the ClockSpeed will work at 1M but sometimes you have to change it after you generate the code.
If you have a scope, See if you are getting any wiggles at all on the I2C.
And until it gets working - keep you i2C wires short.