Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
I am using the VL53L0X sensor with an STM32F103C8 microcontroller and want to communicate with the sensor directly over I2C without using ST’s library. My goal is to minimize project size and better understand the low-level protocol.
I’ve initialized the I2C interface using CMSIS and am sending commands like setting the control register and reading measurement data, but I’m getting inconsistent responses.
See how I initialized the i2c:
// I2C initialization using CMSIS
I2C1->CR1 |= I2C_CR1_PE;
I2C1->CR2 |= (36 << I2C_CR2_FREQ_Pos);
I2C1->CCR = 180;
I2C1->TRISE = 37;
// Sending and reading I2C data
I2C1->DR = (VL53L0X_ADDR << 1);
while (!(I2C1->SR1 & I2C_SR1_TXE)) {}
I2C1->DR = REG_COMMAND;
while (!(I2C1->SR1 & I2C_SR1_RXNE)) {}
uint8_t response = I2C1->DR;
Has anyone successfully worked with the VL53L0X directly over I2C without the library? Any tips on improving communication?
If the ST library is necessary, could someone explain how to integrate it with CMSIS? I prefer CMSIS due to size constraints and learning purposes, but I’m open to using the library if needed.
Any help would be appreciated!
CONTRIBUTE TO THIS THREAD