This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P401R
Hi all,
I am attempting to interface my MSP432P401R MCU with a VL6180X proximity sensor on a breakout board purchased from Adafruit. I have gotten it working with an Arduino and the library provided by Adafruit. When I attempt to use the sensor with the MSP432, I can read the registers using I2C. However, I am encountering an error with the sensor that says I have a "VCSEL Continuity Error". I am not sure what this means, but because I am able to successfully read the registers from the sensor, I have to assume that I am having issues writing to the registers on the sensor. Does anyone have experience with this particular sensor?
Hi Bruce,
Thanks for looking into the library. Yes, I am writing all of those registers. Though they don't offer explanations in the Arduino library, STMicroelectronics (the manufacturer of the VL6180X) has documentation available on their website such as datasheets and C libraries that explain that those are private registers that need to be written for proper initialization of the sensor.
I have tried reading back some of those libraries after I have written them and I keep getting 0 as output. I guess this means that I'm not writing the registers correctly.
However, I'm not sure what is going wrong. When I read from a register, I have to write to the sensor first with the correct register address. I'm pretty sure I'm doing the read operation correctly because I can correctly get the device ID from the 0x0000 register. Additionally, when I do my write operation, I use
int configRegWriteInitVL(uint16_t reg, uint8_t data) { MAP_I2C_setSlaveAddress(EUSCI_B1_BASE, VL_6180X_ADDR); printf("writing\n"); MAP_I2C_setMode(EUSCI_B1_BASE, EUSCI_B_I2C_TRANSMIT_MODE); uint8_t regLSB = reg & 0xFF; uint8_t regMSB = reg >> 8; int result = false; MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, regMSB); MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, regLSB); result = MAP_I2C_masterSendMultiByteFinishWithTimeout(EUSCI_B1_BASE, data, TEMP_TIMEOUT); printf("write result: %d\n", result); return result; }
and when I am writing the registers, it prints out "write result: 1" for all of the write operations, which indicates that the writes were completed successfully. Do you have any insights on what could be going wrong?
I should also note that this is what my read operation looks like:
uint8_t configReadRegVL(uint16_t reg) { int result = false; uint8_t range = 0; uint8_t regLSB = reg & 0xFF; uint8_t regMSB = reg >> 8; MAP_I2C_setSlaveAddress(EUSCI_B1_BASE, VL_6180X_ADDR); MAP_I2C_setMode(EUSCI_B1_BASE, EUSCI_B_I2C_TRANSMIT_MODE); MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, regMSB); result = MAP_I2C_masterSendMultiByteFinishWithTimeout(EUSCI_B1_BASE, regLSB, TEMP_TIMEOUT); if (result == true) { printf("vl read success\n"); MAP_I2C_setMode(EUSCI_B1_BASE, EUSCI_B_I2C_RECEIVE_MODE); range = MAP_I2C_masterReceiveSingleByte(EUSCI_B1_BASE); printf("regvalue: %d\n", range); } return range; }
Additionally, the "unexplained write operations" you mentioned that appeared in the Adafruit library are initializers that written when the device is reset. Thus, theoretically, if I use the sensor with the Arduino first and then don't use the initializers when I use the sensor with the MSP, the sensor should already be initialized correctly. However, I did that and it still gives me the VCSEL error. I don't know if this information helps or makes the problem even more complicated.
Hi Bruce,
Thanks for looking through the Adafruit documentation. The register RESULT_RANGE_STATUS (0x4D) is checked in the readRange() method in the Adafruit library. I have attempted to ignore the error code before I posted on the forum, and the sensor returns a value of 0 for every measurement.
Hi Bruce,
Sorry for the delayed response. I did not go into school over the weekend and I forgot to take the sensor home with me. I tried wiggling the GPIO0 (SHDN) pin to reset it before the program started and the same error occurred.
I also read the register before doing any setup and interestingly enough, it returned 0x01 which means no error. However, immediately after that, I read the device ID register and it returned the wrong value. Then, when I read the problematic register again, it returned the VCSEL Continuity error. I tried doing the above steps with wiggling the SHDN pin and not wiggling the SHDN pin, and the same thing occurred both times.
I also tried using the 5V output on the Launchpad and I still got the same error.
I really appreciate the effort you're putting into helping me but right now, it's looking like this is an error that can't be fixed. Sorry for wasting your time.
Hi Bob,
Sorry for the lack of response. It turns out that the sensor sometimes works if I toggle the reset pin. This has a very low success rate and doesn't really help too much. I am not sure what to do from here, but I got it working for long enough to finish my class project. Thanks for all the help!
**Attention** This is a public forum