Skip to main content
Visitor II
November 25, 2015
Question

VL6180 always returning 0x19 from RESULT_RANGE_STATUS (VCSEL Continuity Error)

  • November 25, 2015
  • 1 reply
  • 607 views
Posted on November 25, 2015 at 22:13

I have bought a Sparkfun VL6180 Sensor Board and connected it to a STM32F415 MikroE Mini M4 MCU.  I can correctly talk to it by asking the Model ID, (which returns 0xB4 correctly), but the RESULT_RANGE_STATUS register (0x4D) always returns 0x19 (0b00011001) which according to the VL6180 datasheet means that it has a VCSEL continuity error (bits 7:4 or 0b0001).  I have gotten this from multiple different VL6180 sensors now, so I'm not sure what is going on.

In addition, the SYSTEM_FRESH_OUT_OF_RESET (0x16) register is always returning 0, even after rebooting the system.

Does anyone have any ideas as to what I can do to diagnose the problem, or is anyone else experiencing this problem? 
    This topic has been closed for replies.

    1 reply

    dan239955Author
    Visitor II
    December 2, 2015
    Posted on December 02, 2015 at 20:36

    I fixed the problem, but I wanted to post it here in case anyone else ran into it.  When reading/writing to a 16 bit register on the VL6180x, it is very important to consider endianness.  The STM32 uses little endian byte ordering, but the expected byte order across the wire for the 16 bit register is big endian.  In other words, instead of this:

      uint16_t registerAddress;

     .....

      HAL_I2C_Master_Transmit(&hI2C,deviceAddress,(uint8_t *)&registerAddress,2,timeoutMillis);

    I did this:

      uint8_t temp[2]={0,0};

      temp[0] = (registerAddr >> 8) & 0xFF;

      temp[1] = registerAddr & 0xFF;

      HAL_I2C_Master_Transmit(&hI2C,deviceAddress,temp,2,timeoutMillis);