2015-11-25 01:13 PM
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?2015-12-02 11:36 AM
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 *)®isterAddress,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);