cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X Interrupt not working, No measurements

AVR_embedded
Associate

Hi, I am having trouble with the interrupt. I manange to coummunicate via I2C and read Model ID and Type. But my problem is that i can't initiate the sensor via the VL53L1X_SensorInit() function in the Ultra Lite Driver I'm using. When I debug I see that the program gets stuck in the wait for new data from the sensor in VL53L1X_CheckForDataReady(). In this function the polarity of the interrupt is read as 0x00 and the GPIO__TIO_HV_STATUS as 0x03. Bit 0 in GPIO__TIO_HV_STATUS and the interrupt polarity must be equal for the program to interpret this as data is ready (i.e. a measurement has been made and can be read). A strange thing is that the interrupt polarity is 0x00 (active low) by default even if the manual says active high. And if I try to set the polarity to active high using the dedicated function it will still be active low. If I plug in a logic analyzer I can see that the GPIO1 (Interrupt output) from the sensor is high all the time. I then tested the sensor with the Arduino library and code and it worked fine and I could see the shift in GPIO output first time i tried it. Thereafter however it still produced distance values but I could not see the shift in GPIO level. The GPIO was high all the time.

Could someone please help me with this? It is part of a school project which I have to finish soon... 🙂

THANK YOU!

*****************************************************************************************************************************

setup_i2c();

// Reset Sensor
status = VL53L1_WrByte(dev, SOFT_RESET, 0x00); //Reset
_delay_ms(100);
status = VL53L1_WrByte(dev, SOFT_RESET, 0x01); // Exit Reset
_delay_ms(1000);

// Wait for sensor boot
while(sensorState == 0){
status = VL53L1X_BootState(dev, &sensorState);
_delay_ms(10); // 10 msec delay
}

/* Those basic I2C read functions can be used to check your own I2C functions */
status = VL53L1_RdByte(dev, 0x010F, &byteData);
//printf("VL53L1X Model_ID: %X\n", byteData);
status = VL53L1_RdByte(dev, 0x0110, &byteData);
//printf("VL53L1X Module_Type: %X\n", byteData);
status = VL53L1_RdWord(dev, 0x010F, &wordData);
//printf("VL53L1X: %X\n", wordData);

VL53L1X_SetInterruptPolarity(dev, 0x01);
_delay_ms(1000);
VL53L1X_GetInterruptPolarity(dev, &int_pol);

/* Init VL53L1X */
VL53L1X_SensorInit(dev);

************************************************************************************************************

VL53L1X_ERROR VL53L1X_SensorInit(uint16_t dev)
{
VL53L1X_ERROR status = 0;
uint8_t Addr = 0x00, tmp;
 
for (Addr = 0x2D; Addr <= 0x87; Addr++){
status |= VL53L1_WrByte(dev, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D]);
}
    VL53L1X_GetInterruptPolarity(dev, &tmp);    // ADDED CHECK!!
 
status |= VL53L1X_StartRanging(dev);
tmp  = 0;
while(tmp==0){
status |= VL53L1X_CheckForDataReady(dev, &tmp);
}
status |= VL53L1X_ClearInterrupt(dev);
status |= VL53L1X_StopRanging(dev);
status |= VL53L1_WrByte(dev, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09); /* two bounds VHV */
status |= VL53L1_WrByte(dev, 0x0B, 0); /* start VHV from the previous temperature */
return status;
}
*********************************************************************************************************************************
VL53L1X_ERROR VL53L1X_CheckForDataReady(uint16_t dev, uint8_t *isDataReady)
{
uint8_t Temp;
uint8_t IntPol;
VL53L1X_ERROR status = 0;
 
status |= VL53L1X_GetInterruptPolarity(dev, &IntPol);
status |= VL53L1_RdByte(dev, GPIO__TIO_HV_STATUS, &Temp);
/* Read in the register to check if a new value is available */
if (status == 0){
if ((Temp & 1) == IntPol)
*isDataReady = 1;
else
*isDataReady = 0;
}
return status;
}
3 REPLIES 3
Zhiyuan.Han
ST Employee

Hi 

Few things worth to check for your problem.

  1. Check if the sensor is really working by taking a video with a non-apple phone, if the sensor start working, the camera could capture the VCSEL light. 
  2. Maybe some I2C function was not well implemented, I2C bus read and write functions, I attached a guide, you can validate you I2C bus function are all correct. 
  3. Sensor side GPIO configuration, the interrupt pin is open-drain GPIO, you need pull-up with a 47K resistor. 
  4. The host side GPIO configuration, below is an example from STM32 F401 example code.ZhiyuanHan_0-1710899497655.png

     

  5. Follow the UM and example code in the link:X-CUBE-53L1A1 - Long Distance Ranging sensor software expansion for STM32Cube - STMicroelectronics

 

Br

Zhiyuan.Han


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AVR_embedded
Associate

Hi, and thank you for your reply.

I checked the things on your list:

1. I couldn't see any light in a slow motion video, but I know it's working with the Arduino code as I mentioned.

Maybe I will try it with the Arduino code.

2. The I2C read/write functions are working properly which I have seen with a logic analyzer.

3. The sensor is mounted on a breakout board with a 47k pull-up resistor.

4. I'm a little bit unsure about this part but I don't read the GPIO1 from the sensor with the MCU. I monitored it with the logic analyzer.

5. I used an example code from the beginning when creating my program and it's almost identical to mine.

I plugged in the analyzer again and I saw that the default configuration with address 0x30 = 0x01 (INT active high) was written together with the rest of the configuration to the registers. But when calling VL53L1X_GetInterruptPolarity() from VL53L1X_CheckForDataReady() it returns polarity 0 and reads 0x31 = 0x03 which means that interrupt is active low and interrupt is currently high (bit 0 in 0x31).  

Hi 

Your issue seems quite strange, please check your hardware connection, or change a new module to try.

  • The default configuration with address 0x30 = 0x01 (INT active high), no problem here.
  • When calling VL53L1X_GetInterruptPolarity() from VL53L1X_CheckForDataReady() it returns polarity 0 . here is something went wrong.  sensor was not able to change the setting by himself.  
  •  reads 0x31 = 0x03; With default interrupt active high setting, no problem. 

 

Br

Zhiyuan.Han

 

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.