cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt GPIO VL53L0X

jonas m
Associate II
Posted on February 21, 2018 at 14:47

hi,  

how does the Vl53L0X ranging sensor adress the GPIO for the interrupt, i can only find a long list of register adresses in the vl53l0x_interrupt_threshold_settings.h.

After initialization and calibration of the Sensor, i tried it with the code below. However, no interrupt is given out in StartMeasurement(). Im using the stm32f103RE microcontroller.

FixPoint1616_t threshold_high=(255);

FixPoint1616_t threshold_low=(350);

    status= VL53L0X_SetInterruptThresholds(pTestDev,

                    VL53L0X_DEVICEMODE_SINGLE_RANGING, threshold_low ,

                    threshold_high);

 status=VL53L0X_SetGpioConfig(pTestDev,0,VL53L0X_DEVICEMODE_SINGLE_RANGING,VL53L0X_GPIOFU                                 NCTIONALITY_THRESHOLD_CROSSED_LOW, VL53L0X_INTERRUPTPOLARITY_LOW);

    status=VL53L0X_StartMeasurement(pTestDev);

best regards

jonas

#interrupt #vl53l0x #stm32f103 #interrupt-status-register
4 REPLIES 4
just4you
Associate II
Posted on May 29, 2018 at 11:55

I think your configuration means measurement would be run once.

so I think you should change the configuration from single to continuous measurements.

Then, the probability of interrupt occurrence would be increased.

When an interrupt occurs, the interrupt mask should be cleared.

Refer the configuration of

AlarmDemo()

function in en.X-CUBE-53L0A1.

http://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32cube-expansion-software/stm32-ode-sense-sw/x-cube-53l0a1.html

 

The code flows like these.

----------------------------------------------------------------------------------------------------------------------------------------------------------------

.

.

.

VL53L0X_SetDeviceMode(VL53L0X_DEVICEMODE_CONTINUOUS_RANGING);

.

.

.

VL53L0X_SetGpioConfig(VL53L0X_DEVICEMODE_CONTINUOUS_RANGING);

VL53L0X_ClearInterruptMask();

VL53L0X_StartMeasurement();

VL53L0X_GetRangingMeasurementData();

VL53L0X_ClearInterruptMask();

jonas m
Associate II
Posted on June 11, 2018 at 14:44

I did it with a poll now. With high speed measurement, there is not much time wasted i guess. I will cange it to interrupt later on. Thanks!

Posted on June 14, 2018 at 05:15

The poll function of data measurement takes several hundreds of micro seconds.

So, you should consider this time works as blocking.

If this blocking time leads critical effect to your system,

then you should modify all blocking functions to none blocking functions.

Device the VL53L0x API functions and modify platform function as none blocking.

※ In my experience, the DMA functions of I2C shows more stable than Interrupt functions.

jonas m
Associate II
Posted on June 25, 2018 at 13:40

The entire measurement cycle is about 40ms now with the poll. I think for my system the blocked time is not critical, cause the MC waits for the result anyway.

However after changing the measurement to CONTINUOUS_RANGING, the GetRangingMeasurementData() shows error 3. Thats Min Range Fail and according to the manual UM2039 page 16 not even set by default. The error occurs  2 seconds after reset, before that the measurement is achieved without any error. I tried some delay to get time for the buffer, but that only delays the time till the error.

In deviation to your previous code, i did everything with a poll and didn't designed the hardware for interrupt.

   oldtime=HAL_GetTick();

      /*Ask for measurement data ready and wait 40 ms till data is ready */

      while ((MeasurementDataReady[k]!=1)&&(time<=40)) {

           newtime=HAL_GetTick();

           time=newtime-oldtime;

        status[10]=VL53L0X_GetMeasurementDataReady();

        }

        /*Store measurement data in struct on device*/

       status[11]=VL53L0X_GetRangingMeasurementData();    

       status[12]=VL53L0X_ClearInterruptMask();

  • Edit: Sounds like an error of an interrupt, and it was. After uncommeting the interrupt, the measurement data is like it is supposed to. The code is working.