cancel
Showing results for 
Search instead for 
Did you mean: 

X-CUBE-TOF1 with custom STM32H7 hardware

hxtec32
Associate

Hi all,

I recently purchased an STM32H723VGT6 breakout board [https://github.com/WeActStudio/WeActStudio.MiniSTM32H723] (not a NUCLEO) and a VL53L5CX sensor breakout from Pololu [https://www.pololu.com/product/3417], and, as I'm a beginner and struggling to navigate all the literature as it relates to STM32, I was wondering if anyone here could give me a step-by-step guide on what documents I need to read in order to set up this custom hardware before I design a similar setup myself with an STM32H523 instead of an STM32H723.

I've already went through the user manual, quite a few YouTube videos, and some more stuff, and I'm confused, since I can't seem to find documents on working with X-CUBE-TOF1 and custom hardware.

The main issue I have is the fact that I only want just that two pin I2C connection between the MCU and the sensor and nothing else due to the space constraints of my upcoming custom design [PB10 = SCL, PB11 = SDA]. Therefore, I have done the same in the prototype with the off-the-shelf boards I've bought. I tried setting up 'Board Part Ranging' and 'Board Support STM32Cube Custom BSP drivers', since those didn't throw up errors with the hardware configuration I had already set up, but the platform settings was giving me errors, since I selected I2C2 for the BSP, but in the 'application' section of 'Platform proposal', I didn't have PWR_EN, LPn, I2C_RST pins since they aren't in the prototype circuit I've made.

15:20:08 **** Incremental Build of configuration Debug for project H723_VL53L5CX ****

make -j24 all

arm-none-eabi-gcc "../X-CUBE-TOF1/Target/custom_ranging_sensor.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32H723xx -c -I../Core/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32H7xx/Include -I../Drivers/CMSIS/Include -I../X-CUBE-TOF1/Target -I../Drivers/BSP/Components/vl53l7cx/modules -I../Drivers/BSP/Components/vl53l7cx/porting -I../Drivers/BSP/Components/vl53l7cx -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"X-CUBE-TOF1/Target/custom_ranging_sensor.d" -MT"X-CUBE-TOF1/Target/custom_ranging_sensor.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "X-CUBE-TOF1/Target/custom_ranging_sensor.o"

arm-none-eabi-gcc "../Core/Src/system_stm32h7xx.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32H723xx -c -I../Core/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc -I../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32H7xx/Include -I../Drivers/CMSIS/Include -I../X-CUBE-TOF1/Target -I../Drivers/BSP/Components/vl53l7cx/modules -I../Drivers/BSP/Components/vl53l7cx/porting -I../Drivers/BSP/Components/vl53l7cx -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/system_stm32h7xx.d" -MT"Core/Src/system_stm32h7xx.o" --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -o "Core/Src/system_stm32h7xx.o"

../X-CUBE-TOF1/Target/custom_ranging_sensor.c: In function 'reset_device':

../X-CUBE-TOF1/Target/custom_ranging_sensor.c:475:21: error: 'CUSTOM_VL53L7CX_PWR_EN_PORT' undeclared (first use in this function); did you mean 'CUSTOM_VL53L7CX_I2C_INIT'?

475 | HAL_GPIO_WritePin(CUSTOM_VL53L7CX_PWR_EN_PORT, CUSTOM_VL53L7CX_PWR_EN_PIN, GPIO_PIN_RESET);

| ^~~~~~~~~~~~~~~~~~~~~~~~~~~

| CUSTOM_VL53L7CX_I2C_INIT

../X-CUBE-TOF1/Target/custom_ranging_sensor.c:475:21: note: each undeclared identifier is reported only once for each function it appears in

../X-CUBE-TOF1/Target/custom_ranging_sensor.c:475:50: error: 'CUSTOM_VL53L7CX_PWR_EN_PIN' undeclared (first use in this function); did you mean 'CUSTOM_VL53L7CX_I2C_INIT'?

475 | HAL_GPIO_WritePin(CUSTOM_VL53L7CX_PWR_EN_PORT, CUSTOM_VL53L7CX_PWR_EN_PIN, GPIO_PIN_RESET);

| ^~~~~~~~~~~~~~~~~~~~~~~~~~

| CUSTOM_VL53L7CX_I2C_INIT

../X-CUBE-TOF1/Target/custom_ranging_sensor.c:479:21: error: 'CUSTOM_VL53L7CX_LPn_PORT' undeclared (first use in this function); did you mean 'CUSTOM_VL53L7CX_I2C_INIT'?

479 | HAL_GPIO_WritePin(CUSTOM_VL53L7CX_LPn_PORT, CUSTOM_VL53L7CX_LPn_PIN, GPIO_PIN_RESET);

| ^~~~~~~~~~~~~~~~~~~~~~~~

| CUSTOM_VL53L7CX_I2C_INIT

../X-CUBE-TOF1/Target/custom_ranging_sensor.c:479:47: error: 'CUSTOM_VL53L7CX_LPn_PIN' undeclared (first use in this function); did you mean 'CUSTOM_VL53L7CX_I2C_INIT'?

479 | HAL_GPIO_WritePin(CUSTOM_VL53L7CX_LPn_PORT, CUSTOM_VL53L7CX_LPn_PIN, GPIO_PIN_RESET);

| ^~~~~~~~~~~~~~~~~~~~~~~

| CUSTOM_VL53L7CX_I2C_INIT

make: *** [X-CUBE-TOF1/Target/subdir.mk:19: X-CUBE-TOF1/Target/custom_ranging_sensor.o] Error 1

make: *** Waiting for unfinished jobs....

"make -j24 all" terminated with exit code 2. Build might be incomplete.

 

15:20:09 Build Failed. 6 errors, 0 warnings. (took 1s.31ms)

Also, if there's any other literature you could recommend as it relates to using data interfaces like I2C, SPI, I3C, etc, with sensors, PMICs, even other MCUs, I would really appreciate it. Currently, my software knowledge lags so far behind my hardware and PCB design knowledge right now that I am limiting my ability to use smarter chips with STM32 which require I2C configuration because I'm hesitant on having to write the drivers and stuff by myself. With Arduino and ESP32, I was so used to being spoon-fed with easy-to-use libraries and not even seeing all the HAL stuff, so starting to move into STM32 I felt was a great way to fill this gap in my knowledge while learning how to optimise for better performance, power consumption, etc.

Thank you so much, all help is appreciated.

1 REPLY 1
John E KVAM
ST Employee

Given what you have said, perhaps we could try something different.

Use the X-Cube (or STM32CubeMXIDE) and get your MCU running and establish where your I2C is going. 

In theory the VL53L7 needs PWR, GND, SCL and SDA. 

But then you realize you also need to pull the XShut line High, and maybe hook up the interrupt line. 

But simply start getting your MCU running without the sensor. 

ONce there download the VL53L7 API.

The CubeMX_ToF1 does some interesting things so they can run all the ToF sensors with one set of software. But the L7 API is easier to use - and there are examples. 

Som when you have your MCU running, you can port one of the L7 examples into your project. 

It has all the code you need - you only need to pay attention to the I2C functions to make sure they go to the right pins. 

the code to look at is:

STSW-IMG036

Ultra lite driver (ULD) API for the VL53L7CX Time-of-Flight 8x8 multizone ranging sensor with 90 degrees FoV

Good luck.

 


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.