2024-03-15 09:29 AM
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);
************************************************************************************************************
2024-03-19 06:57 PM
Hi
Few things worth to check for your problem.
Br
Zhiyuan.Han
2024-03-20 04:39 AM
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).
2024-03-25 02:50 AM
Hi
Your issue seems quite strange, please check your hardware connection, or change a new module to try.
Br
Zhiyuan.Han
2024-12-24 10:34 AM
We are on the same page! I'm having same issues but with an vl53l4cx.
All steps for the configuration pass OK, no errors are received, but the interrupt is never generated. When using a generic arduino everything works, but when using an esp32 with the arduino library adapted for esphome no interupts are generated so no values are read.
Did you solve your issue?
Thanks!
2024-12-24 11:17 AM
The sensor really cannot fail to set the interrupt, but it could be that the interrupt was already set and one cannot set it again. I'm going to guess you need to clear the interrupt before you start the sensor. Once cleared, it should be set when the ranging completes.
If you run the debugger ,stop the code just after clearing the interrupt and check the line, then range and check it again.
It's all I can think of.
And one does have to clear the interruupt after each range.