Skip to main content
Visitor II
October 20, 2023
Question

VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO always 0

  • October 20, 2023
  • 3 replies
  • 1279 views

when I use vl6810  with 51 chip , the  i2c use pull up to 1.8V  。

all the init register is correctly, I Using an oscilloscope for detection ,It seems all correct。

but it always wait at VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO here :

while(!(VL6180X_ReadByte(VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO)&0x04));

it  always read 0 ,It took me a long time and I couldn't find where the problem

But if I use STM32 as the MCU, everything will be fine。   

 

 

 

    This topic has been closed for replies.

    3 replies

    QZHAuthor
    Visitor II
    October 20, 2023

    The code is as follows:

    uint8_t VL6180X_Init(void)
    {
        if(VL6180X_Read_ID() == VL6180X_DEFAULT_ID)
        {
            VL6180X_WriteByte(0x0207, 0x01);
            VL6180X_WriteByte(0x0208, 0x01);
            VL6180X_WriteByte(0x0096, 0x00);
            VL6180X_WriteByte(0x0097, 0xfd);
            VL6180X_WriteByte(0x00e3, 0x00);
            VL6180X_WriteByte(0x00e4, 0x04);
            VL6180X_WriteByte(0x00e5, 0x02);
            VL6180X_WriteByte(0x00e6, 0x01);
            VL6180X_WriteByte(0x00e7, 0x03);
            VL6180X_WriteByte(0x00f5, 0x02);
            VL6180X_WriteByte(0x00d9, 0x05);
            VL6180X_WriteByte(0x00db, 0xce);
            VL6180X_WriteByte(0x00dc, 0x03);
            VL6180X_WriteByte(0x00dd, 0xf8);
            VL6180X_WriteByte(0x009f, 0x00);
            VL6180X_WriteByte(0x00a3, 0x3c);
            VL6180X_WriteByte(0x00b7, 0x00);
            VL6180X_WriteByte(0x00bb, 0x3c);
            VL6180X_WriteByte(0x00b2, 0x09);
            VL6180X_WriteByte(0x00ca, 0x09);
            VL6180X_WriteByte(0x0198, 0x01);
            VL6180X_WriteByte(0x01b0, 0x17);
            VL6180X_WriteByte(0x01ad, 0x00);
            VL6180X_WriteByte(0x00ff, 0x05);
            VL6180X_WriteByte(0x0100, 0x05);
            VL6180X_WriteByte(0x0199, 0x05);
            VL6180X_WriteByte(0x01a6, 0x1b);
            VL6180X_WriteByte(0x01ac, 0x3e);
            VL6180X_WriteByte(0x01a7, 0x1f);
            VL6180X_WriteByte(0x0030, 0x00);
           
            // Recommended : Public registers - See data sheet for more detail
            VL6180X_WriteByte(0x0011, 0x10);       // Enables polling for 'New Sample ready'
                                        // when measurement completes
            VL6180X_WriteByte(0x010a, 0x30);       // Set the averaging sample period
                                        // (compromise between lower noise and
                                        // increased execution time)
            VL6180X_WriteByte(0x003f, 0x46);       // Sets the light and dark gain (upper
                                        // nibble). Dark gain should not be
                                        // changed. !???????0x4 ?????1.0
            VL6180X_WriteByte(0x0031, 0xFF);       // sets the # of range measurements after
                                        // which auto calibration of system is
                                        // performed
            VL6180X_WriteByte(0x0040, 0x63);       // Set ALS integration time to 100ms
            VL6180X_WriteByte(0x002e, 0x01);       // perform a single temperature calibration
                                        // of the ranging sensor

            // Optional: Public registers - See data sheet for more detail
            VL6180X_WriteByte(0x001b, 0x09);    //????  ????
                                        // period to 100ms  ??10ms->0-10ms
            VL6180X_WriteByte(0x003e, 0x31);      //????    ALS??
                                        // to 500ms    
            VL6180X_WriteByte(0x0014, 0x24);       // Configures interrupt on 'New Sample
                                        // Ready threshold event'
            return 0;
        }
        else return 1;
    }

    //????
    uint8_t VL6180X_Read_Range(void)
    {
        uint8_t range = 0;
        //????
        while(!(VL6180X_ReadByte(VL6180X_REG_RESULT_RANGE_STATUS) & 0x01));
        VL6180X_WriteByte(VL6180X_REG_SYSRANGE_START,0x01); //??????
        //???????????(New Sample Ready threshold event)
        while(!(VL6180X_ReadByte(VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO) & 0x04));
        range = VL6180X_ReadByte(VL6180X_REG_RESULT_RANGE_VAL);
        //???????????
        VL6180X_WriteByte(VL6180X_REG_SYSTEM_INTERRUPT_CLEAR,0x07); //0111b ?????????
        return range;
    }
    QZHAuthor
    Visitor II
    October 20, 2023

    1.8V is directly pulled up, STM32 has undergone level conversion, GPIO0 is pulled up to 2.8V, GPIO1 NC

    Visitor II
    September 15, 2024

    I am having the same problem but do not understand what the solution is?

    I am using the VL6180X on a Arduino Nano 33BLE and the code keeps hanging at this exact same line?

    What is the solution? I am completely lost...