Multiple VL53L1X interrupt mode
For my project, I need to use 2 Vl53L1X on the same I2C bus. The setup is good and i can use them sequentially. But I would like use them in interrupt mode (for have a maximum speed).
In short/interrupt mode with one sensor i have 20ms time beetween 2 measurements.
But with two sensors the minimum time is about 45ms.
Timming congiguration :
status = VL53L1_SetDistanceMode(Device01, VL53L1_DISTANCEMODE_SHORT);
status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Device01, 20000);
status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Device01, 24);
status = VL53L1_SetDistanceMode(Device02, VL53L1_DISTANCEMODE_SHORT);
status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Device02, 20000);
status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Device02, 26);
Main loop
do{
status = VL53L1_StartMeasurement(Device01);
status = VL53L1_StartMeasurement(DeviceSol);
__WFI();
if(IntCount2 !=0 ){
IntCount2=0;
if (firstTimeInterrupt ==0){
status = VL53L1_GetRangingMeasurementData(Device01, &RangingDataPneu);
if(status==0){
end = (int)HAL_GetTick();
printf("Temps PNEU %i ms \n\r",end-start);
printf("Mesure PNEU = %d\n\r",RangingDataPneu.RangeMilliMeter);
start = (int)HAL_GetTick();
}
status = VL53L1_ClearInterruptAndStartMeasurement(Device01);
}
else{ //Must not read data at the first interrupt, must clear interrupt and start measurement
status = VL53L1_ClearInterruptAndStartMeasurement(Device01);
firstTimeInterrupt = 0;
//printf("[else ] \n\r");
}
}
if(IntCount !=0 ){
IntCount=0;
if (firstTimeInterrupt2 ==0){
status = VL53L1_GetRangingMeasurementData(Device02, &RangingDataSol);
if(status==0){
end1 = (int)HAL_GetTick();
printf("Temps SOL %i ms \n\r",end1-start1);
printf("Mesure SOL = %d\n\r",RangingDataSol.RangeMilliMeter);
start1 = (int)HAL_GetTick();
}
status = VL53L1_ClearInterruptAndStartMeasurement(Device02);
}
else{ //Must not read data at the first interrupt, must clear interrupt and start measurement
status = VL53L1_ClearInterruptAndStartMeasurement(Device02);
firstTimeInterrupt2 = 0;
//printf("[else ] \n\r");
}
}
}while(1);
Interrupt configuration
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin==VL53_PIN_Pin)
{
IntCount++;
}
if (GPIO_Pin==GPIO_PIN_9)
{
IntCount2++;
}
}
I would like to know if it's possible and how configure a programm to have the maximum speed.
Thanks
Best Regards
