2018-11-09 06:49 AM
Hi all,
I am trying to get the VL6180X to work with my TI MSP432P401R Microcontroller. I purchased my VL6180X on a breakout board manufactured by Adafruit (https://www.adafruit.com/product/3316). I have gotten it working with an Arduino just to verify that the sensor is functional, and I am using the libraries created by Adafruit specifically for the VL6180X sensor (https://github.com/adafruit/Adafruit_VL6180X).
However, when I try to use it with my TI microcontroller, it stops working. On my TI microcontroller, I have essentially copied the Adafruit Arduino code and modified it slightly so that it can work with the TI microcontroller. The I2C read function works fine, and I am able to confirm this by reading the device ID from register 0x0000. I am checking the RESULT_RANGE_STATUS register (0x04D) before I start a range measurement, and I am getting a register value of decimal 25, which would be binary 00011001. According to the VL6180X datasheet, this means that I am encountering a VCSEL Continuity Test error. The VL6180X error codes explanation document says that if I encounter this error, I should reset the device and if the issue continues, I should stop using the device. I have tried resetting the device by writing to the mandatory private and optional public registers as found in the vl6180x_api.c file that I downloaded from the STM website. However, this does not resolve the problem. I have even tried running the sensor first on the Arduino, which resets the sensor, and then connecting it to my TI microcontroller. This still produces the same VCSEL Continuity Test error, and I am not sure what to do. Does anyone have any input?
2019-04-22 11:03 AM
Every time I have gone wrong, it has to do with the I2C byte-swap. If it works on one MCU and not on the other, the first thing I would carefully examine is the endianness of your device. As the chip ID is one byte you can get that to work, and still have trouble transmitting words and longwords.