cancel
Showing results for 
Search instead for 
Did you mean: 

vl53l5cx_init fails in _vl53l5cx_poll_for_mcu_boot

Kuhaku
Associate

I am trying to use the VL53L5CX with Zephyr. The read and write functions of the platform files seem to work well, but when running an example and attempting to initialize the sensor, when I reach the point of resetting the MCU, I receive a 255 from register 0x07, which stores the value in go2_status1. According to the UDL documentation, this is a timeout or I2C error, but I don't know what could be causing it. The I2C address of the device is correctly configured, and I am unsure about the cause of the timeout. Any ideas? Thank you very much.

1 REPLY 1
Anne BIGOT
ST Employee

Hello,
Are you sure the I2C communication is well settle ?
Could be good to check it.

Please find some code that could help to check the I2C communication :

 

/* --------------------------------------------------
* --- This function can be used to test VL53L5CX I2C 
* --------------------------------------------------
*/

uint8_t vl53l5cx_test_i2c(VL53L5CX_Configuration *p_dev){
uint8_t status = VL53L5CX_STATUS_OK;
printf("Starting VL53L5CX I2C test...\n");

/* To check the I2C RdByte/WrByte function :
* Inside the function “vl53l5cx_is_alive()”, it will call I2C RdByte/WrByte to
* read device and verion ID. which can help you to verify the I2C RdByte/WrByte
* functions at same time.
*/
uint8_t device_id, revision_id;
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= RdByte(&(p_dev->platform), 0, &device_id);
status |= RdByte(&(p_dev->platform), 1, &revision_id);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);

if(status)
{
 printf("Error Rd/Wr byte: status %u\n", status);
 return status;
}

/* To check the I2C RdMulti/WrMulti function:
* Below is example codes which can help you vefify the I2C RdMulti/WrMulti
* function.
*/

uint8_t Data_write[4]={0x5A,0xA5,0xAA,0x55};
uint8_t Data_read[4]={0,0,0,0};
uint8_t Data_default[4]={0,0,0,0};

status |= RdMulti(&(p_dev->platform), 0x100, Data_default, 4);
if(status)
{
 printf("Error RdMulti: status %u\n", status);
 return status;
}

printf("Read default value and save it at begging\n");
printf("Data_default (0x%x)\n", Data_default[0]);
printf("Data_default (0x%x)\n", Data_default[1]);
printf("Data_default (0x%x)\n", Data_default[2]);
printf("Data_default (0x%x)\n", Data_default[3]);

status |= WrMulti(&(Dev.platform), 0x100, Data_write, 4);
if(status)
{
 printf("Error WrMulti: status %u\n", status);
 return status;
}
printf("Writing values 0x5A 0xA5 0xAA 0x55\n");

status |= RdMulti(&(p_dev->platform), 0x100, Data_read, 4);
if(status)
{
 printf("Error RdMulti: status %u\n", status);
 return status;
}

printf("Reading:\n");
printf("Data_read (0x%x)\n", Data_read[0]);
printf("Data_read (0x%x)\n", Data_read[1]);
printf("Data_read (0x%x)\n", Data_read[2]);
printf("Data_read (0x%x)\n", Data_read[3]);


status |= WrMulti(&(Dev.platform), 0x100, Data_default, 4);
printf("Write back default value\n");
if(status)
{
 printf("Error WrMulti: status %u\n", status);
 return status;
}

status |= RdMulti(&(Dev.platform), 0x100, Data_default, 4);
if(status)
{
 printf("Error RdMulti: status %u\n", status);
 return status;
}

printf("Read value again to make sure default value was correct loaded\n");
printf("Data_default (0x%x)\n", Data_default[0]);
printf("Data_default (0x%x)\n", Data_default[1]);
printf("Data_default (0x%x)\n", Data_default[2]);
printf("Data_default (0x%x)\n", Data_default[3]);

printf("I2C test done - everything works fine.\n");

return status;
}

 

Regards


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'