2025-03-26 11:16 PM
Hello ST team, as mentioned in the title, I found that the power consumption when using the ULP library to drive TOF L1 is inconsistent with the manual. I'm using the official evaluation board vl53l1-satel. Below is my test code and power consumption data. In my code, you'll see both ULD and ULP libraries, but I'm actually only using the ULP library; the ULD library is commented out.
int main(void)
{
/* USER CODE BEGIN 1 */
uint16_t dev=0x52;
int status=0;
volatile int IntCount;
uint8_t byteData, sensorState=0;
uint16_t wordData;
uint8_t measurement_status;
uint16_t estimated_distance_mm;
uint16_t sigma_mm;
uint16_t signal_kcps;
uint16_t ambient_kcps;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
MX_TIM16_Init();
MX_LPUART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim16,TIM_CHANNEL_1);
printf("\r\n--MCU ready !--\r\n");
I2C_Scan(&hi2c1);
//while(1)I2C_Scan(&hi2c1);
status = VL53L1_RdByte(dev, 0x010F, &byteData);
printf("VL53L1X Model_ID: %X\r\n", byteData);
status = VL53L1_RdByte(dev, 0x0110, &byteData);
printf("VL53L1X Module_Type: %X\r\n", byteData);
status = VL53L1_RdWord(dev, 0x010F, &wordData);
printf("VL53L1X: %X\r\n", wordData);
while(sensorState==0){
status = VL53L1X_BootState(dev, &sensorState);
HAL_Delay(2);
}
printf("Chip booted\r\n");
/* This function must to be called to initialize the sensor with the default setting */
status = VL53L1X_ULP_SensorInit(dev);
if(status) printf("init error\r\n");
/* Optional functions to be used to change the main ranging parameters according the application requirements to get the best ranging performances */
//VL53L1X_ULP_SetInterruptConfiguration(dev,0,0);
status = VL53L1X_ULP_SetInterMeasurementInMs(dev, 500); /* in ms possible values [20, 50, 100, 200, 500] */
status = VL53L1X_ULP_SetMacroTiming(dev, 20); //MacropPeriod
status = VL53L1X_ULP_SetSignalThreshold(dev, 1600);
status = VL53L1X_ULP_SetSigmaThreshold(dev, 50);
// status = VL53L1X_SetOffset(dev,20); /* offset compensation in mm */
status = VL53L1X_ULP_SetROI(dev, 16); /* minimum ROI 4 */
// status = VL53L1X_CalibrateOffset(dev, 140, &offset); /* may take few second to perform the offset cal*/
// status = VL53L1X_CalibrateXtalk(dev, 1000, &xtalk); /* may take few second to perform the xtalk cal */
printf("VL53L1X Ultra Lite Driver Example running ...\r\n");
status = VL53L1X_ULP_StartRanging(dev); /* This function has to be called to enable the ranging */
if(status) printf("init error\r\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(100);
status = VL53L1X_ULP_DumpDebugData(dev,
&measurement_status,
&estimated_distance_mm,
&sigma_mm,
&signal_kcps,
&ambient_kcps);
if (status == VL53L1X_ULP_ERROR_NONE)
{
printf("Measurement Status: %u ", measurement_status);
printf("Estimated Distance: %u mm ", estimated_distance_mm);
printf("Sigma: %u mm ", sigma_mm);
printf("Signal Rate: %u kcps ", signal_kcps);
printf("Ambient Rate: %u kcps\r\n", ambient_kcps);
}
else
{
printf("Error reading measurement: %d\r\n", status);
}
VL53L1X_ULP_StopRanging(dev);
HAL_Delay(2000);
VL53L1X_ULP_StartRanging(dev);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
//HAL_Delay(1000);
}
/* USER CODE END 3 */
}
2025-08-24 10:48 PM
This image shows the current curve during ranging. The configuration is a 50ms timing budget, a 50ms inter-measurement period, and long-range mode.
By tracing the function calls, I found that VL53L1_ClearInterruptAndStartMeasurement is already called within the VL53L1CB_GetDistance function. The ToF driver and the demo program were generated using CubeMX software.
As a side note, there is a significant difference in power consumption between different library versions.