2023-03-08 05:53 AM
Hi,
I have two vl53l5cx sensors in my system. I need to change (at least one) of the device addresses. I used the instructions from n UM2884, section 2.3, that is.
What could be wrong here?
2023-03-08 06:32 AM
Hello Bob,
I don't know what could be wrong but what I could suggest is to have a look to the code shared within the X-Cube-TOF1 package here and check for the MX_53L5A1_MultiSensorRanging_Init function description in the 53L5A1_MultiSensorRanging example. It could help to port the code.
Anne
static void MX_53L5A1_MultiSensorRanging_Init(void)
{
uint8_t device;
uint16_t i2c_addr;
uint32_t id;
/* Initialize Virtual COM Port */
BSP_COM_Init(COM1);
printf("53L5A1 Multi Sensor Ranging demo application\n");
reset_all_sensors();
/* Turn off all the sensors */
for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)
{
write_lowpower_pin(device, GPIO_PIN_RESET);
}
/* initializes each device and put it in low power mode */
for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)
{
/* enable only one sensor */
write_lowpower_pin(device, GPIO_PIN_SET);
HAL_Delay(2);
status = VL53L5A1_RANGING_SENSOR_Init(device);
if (status != BSP_ERROR_NONE)
{
printf("VL53L3A2_RANGING_SENSOR_Init %d failed\n", device);
ToF_Present[device] = 0; /* device not detected */
}
else
{
ToF_Present[device] = 1; /* device detected */
}
write_lowpower_pin(device, GPIO_PIN_RESET); /* turn off the device */
}
/* power on the devices one at a time and change their address
* once the address is updated, the communication with the devices is checked
* reading its ID.
*/
for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)
{
/* skip the sensor if init not successful */
if (ToF_Present[device] == 0) continue;
/* turn on the device */
write_lowpower_pin(device, GPIO_PIN_SET);
/* left: 0x54, center: 0x56, right: 0x58 */
i2c_addr = (RANGING_SENSOR_VL53L5CX_ADDRESS + (device + 1) * 2);
VL53L5A1_RANGING_SENSOR_SetAddress(device, i2c_addr);
/* check the communication with the device reading the ID */
VL53L5A1_RANGING_SENSOR_ReadID(device, &id);
printf("ToF sensor %d - ID: %04lX\n", device, (unsigned long)id);
}
}