cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the issue where the ULD API of vl53l1x fails to obtain the ranging result

wuyou
Associate

I wrote the i2c communication code for the vl53l1x ULD API in vl53l1_platform.c and i2c32.c, and called the API in tof.c to initialize vl53l1. The VL53L1X_GetSensorId function can correctly read 0xEACC, but the VL53L1X_CheckForDataReady function always shows that the distance measurement is not completed, and at the same time, the VL53L1X_GetDistance also cannot read the distance measurement result.

1 ACCEPTED SOLUTION

Accepted Solutions
Zhiyuan.Han
ST Employee

Hi

 

I see you are using a GPIO simulated I2C, please check you I2C function well. 

 

Below are the codes for I2C read/write function check: 
 
uint8_t byteData;
uint16_t wordData;
uint32_t DwordData;
uint8_t test_buffer_write[4]={0x5A,0xA5,0XAA,0x55};
uint8_t test_buffer_read[4];
 
 
VL53L1_RdByte(Dev, 0x010F, &byteData);
printf("VL53L1X Model_ID: %02X\n\r", byteData);
VL53L1_RdByte(Dev, 0x0110, &byteData);
printf("VL53L1X Module_Type: %02X\n\r", byteData);
VL53L1_RdWord(Dev, 0x010F, &wordData);
printf("VL53L1X: %02X\n\r", wordData);
 
VL53L1_WrWord(Dev, 0x0016, 0x5AA5);
VL53L1_RdWord(Dev, 0x0016, &wordData);
printf("Write 0x5AA5, read value: %02X\n\r", wordData);
 
VL53L1_WrDWord(Dev, 0x0016, 0x5AA5AA55);
VL53L1_RdDWord(Dev, 0x0016, &DwordData);
printf("Write 0x5AA5AA55, read value: %02X\n\r", DwordData);
 
 
VL53L1_WriteMulti(Dev, 0x0016, test_buffer_write,4);
VL53L1_ReadMulti(Dev, 0x0016, test_buffer_read,4);
printf("WriteMulti 4 byte: 0x5AA5AA55\n\r");
printf("ReadMulti 0: %02X\n\r", test_buffer_read[0]);
printf("ReadMulti 1: %02X\n\r", test_buffer_read[1]);
printf("ReadMulti 2: %02X\n\r", test_buffer_read[2]);
printf("ReadMulti 3: %02X\n\r", test_buffer_read[3]);
 
 
Log list as below from Nucleo:
 
 
VL53L1X Model_ID: EA
VL53L1X Module_Type: CC
VL53L1X: EACC
Write 0x5AA5, read value: 5AA5
Write 0x5AA5AA55, read value: 5AA5AA55
WriteMulti 4 byte: 0x5AA5AA55
ReadMulti 0: 5A
ReadMulti 1: A5
ReadMulti 2: AA
ReadMulti 3: 55
 
 
Br
Zhiyuan.Han

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Zhiyuan.Han
ST Employee

Hi

 

I see you are using a GPIO simulated I2C, please check you I2C function well. 

 

Below are the codes for I2C read/write function check: 
 
uint8_t byteData;
uint16_t wordData;
uint32_t DwordData;
uint8_t test_buffer_write[4]={0x5A,0xA5,0XAA,0x55};
uint8_t test_buffer_read[4];
 
 
VL53L1_RdByte(Dev, 0x010F, &byteData);
printf("VL53L1X Model_ID: %02X\n\r", byteData);
VL53L1_RdByte(Dev, 0x0110, &byteData);
printf("VL53L1X Module_Type: %02X\n\r", byteData);
VL53L1_RdWord(Dev, 0x010F, &wordData);
printf("VL53L1X: %02X\n\r", wordData);
 
VL53L1_WrWord(Dev, 0x0016, 0x5AA5);
VL53L1_RdWord(Dev, 0x0016, &wordData);
printf("Write 0x5AA5, read value: %02X\n\r", wordData);
 
VL53L1_WrDWord(Dev, 0x0016, 0x5AA5AA55);
VL53L1_RdDWord(Dev, 0x0016, &DwordData);
printf("Write 0x5AA5AA55, read value: %02X\n\r", DwordData);
 
 
VL53L1_WriteMulti(Dev, 0x0016, test_buffer_write,4);
VL53L1_ReadMulti(Dev, 0x0016, test_buffer_read,4);
printf("WriteMulti 4 byte: 0x5AA5AA55\n\r");
printf("ReadMulti 0: %02X\n\r", test_buffer_read[0]);
printf("ReadMulti 1: %02X\n\r", test_buffer_read[1]);
printf("ReadMulti 2: %02X\n\r", test_buffer_read[2]);
printf("ReadMulti 3: %02X\n\r", test_buffer_read[3]);
 
 
Log list as below from Nucleo:
 
 
VL53L1X Model_ID: EA
VL53L1X Module_Type: CC
VL53L1X: EACC
Write 0x5AA5, read value: 5AA5
Write 0x5AA5AA55, read value: 5AA5AA55
WriteMulti 4 byte: 0x5AA5AA55
ReadMulti 0: 5A
ReadMulti 1: A5
ReadMulti 2: AA
ReadMulti 3: 55
 
 
Br
Zhiyuan.Han

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.