VL53L1X Interrupt not working, No measurements
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);
************************************************************************************************************
