cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L4CD won't init

Wilton
Associate

I'm trying to use a VL53L4CD with a micro.  BTW the platform.c file is wrong.  It says byte swapping is required for big-endian processors.  In reality byte swapping is required for LITTLE=endian processors.  Got past that and a number of other mistakes on my part.  I can read the 16 bit ID (10F-110).  But I can't init the device.  Calls to the init function always return 255.  I have stepped through it and everything looks good until it checks for ready, where it times out waiting.  The ready function reads two bytes, shifting bit 4 of the first one down to bit 0 and inverting it (through a rather convoluted process).  It than compares that to bit 0 of another byte.  The first byte is 0x11, which results in a 0 after the manipulation.  The second byte is a 1, so it always fails.  Since the data sheet doesn't document any of this, I can't move past that.

BTW, after the program gets to this point and fails, accessing the ID word succeeds as an I2C transfer, but returns all 0s.  I have to power cycle the device before I can get a valid ID again.

Any ideas to get over this hurdle would be appreciated.  I've spent a day and a half getting to this point and there isn't a path forward for me at this point.

Wilton Helm

 

1 ACCEPTED SOLUTION

Accepted Solutions
Wilton
Associate

Solved my own problem.  Here's the issue, in case someone else needs it.  It was an I2C issue.

Reading I2C requires two separate transactions first a write with the register address (high byte first) and second a read of the data (which comes back high byte first).

However, writes, since there is no turn-around can combine both in a single transaction--and in fact must do so.  The first data byte is the high byte of the address, followed by the low byte of the address, followed by the most significant byte of the data and continuing through the least significant byte of the data.

I had created appropriate read functions, but I modelled the write functions after them, and writing as two transactions just won't work (hint: the IC assumes, as it must, that the second transaction starts with an address).

 

View solution in original post

1 REPLY 1
Wilton
Associate

Solved my own problem.  Here's the issue, in case someone else needs it.  It was an I2C issue.

Reading I2C requires two separate transactions first a write with the register address (high byte first) and second a read of the data (which comes back high byte first).

However, writes, since there is no turn-around can combine both in a single transaction--and in fact must do so.  The first data byte is the high byte of the address, followed by the low byte of the address, followed by the most significant byte of the data and continuing through the least significant byte of the data.

I had created appropriate read functions, but I modelled the write functions after them, and writing as two transactions just won't work (hint: the IC assumes, as it must, that the second transaction starts with an address).