I think I see an issue. In your code you have:
printf("first start and interrupt%x\n",i2c_read_Byte(VL53L4CD_SYSTEM_START));
printf("I have risen :)\n\n");
//Clearing System Interrupt
I2C_WrByte(VL53L4CD_SYSTEM__INTERRUPT_CLEAR, 0x01);
//stopping ranging
I2C_WrByte(VL53L4CD_SYSTEM_START, (uint8_t)0x80);
and that is not going to work.
Your MCU is a zillion times faster than the sensor. Even adjusting for the slow I2C, you shoved those commands at the sensor a lot faster than the sensor can process them.
So:
- start the sensor.
- Clear the interrupt.
- WAIT for the interrupt to trigger. Depending on how you initialized it, this could be 20-1000ms.
- Then you can stop the sensor if you want.
- And read out the data.
I think your only issue is timing.
And I'd recommend something like:
Status = 0;
Status != I2C_WrByte()
And then every now and again check status to see if it's non-zero.
- john
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.