2024-07-02 02:06 AM
I am using TOF vl53l8cx with stm32wb5mm-dk. I have used this sensor earlier with f407 and it worked completely fine . Now that I am working with a new mcu which only has 1 USART. I am trying to LPUART for BLE and USART1 for tof BSP.
When the function CUSTOM_RANGING_SENSOR_Init(CUSTOM_VL53L8CX)
int32_t CUSTOM_RANGING_SENSOR_Init(uint32_t Instance)
{
int32_t ret;
if (Instance >= CUSTOM_RANGING_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
reset_device();
switch (Instance)
{
#if (USE_CUSTOM_RANGING_VL53L8CX == 1U)
case CUSTOM_VL53L8CX:
if (VL53L8CX_Probe(Instance) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_NO_INIT;
}
else
{
ret = BSP_ERROR_NONE;
}
break;
#endif /* Use custom ranging */
default:
ret = BSP_ERROR_UNKNOWN_COMPONENT;
break;
}
}
return ret;
} is called . The code reaches resetdevice(); function but the inside this function as soon as PWR_EN is raised high the device stops responding.
2024-07-02 08:16 AM
You get to reset_device() because of the line:
if (Instance >= CUSTOM_RANGING_INSTANCES_NBR)
So, use your debugger to find the value of those two.
I'm going to guess those are equal.
And somewhere in the code, CUSTOM_RANGING_INSTANCES_NBR is defined.
I'd add one to this and see what happens.
Is CUSTOM_RANGING_INSTANCES_NBR defineable in the XCube somewhere?
That has to be it.
(But it's only a guess on my part.)
- john
2024-07-03 09:35 PM - edited 2024-07-03 09:51 PM
I tried debugging and the used &&0 with a few values so the device can atleast start working.
while debugging I came across :
2024-07-08 01:49 PM
If power is applied to the sensor, and the LPn is pulled high, the 'poll_for_answer' will respond. The sensor is complex, but the I2C interface is dead simple. Unless you have the i2C/SPI switch wrong. That would cause an issue. Pull it down for I2C.
if you don't get that far, then somehow you have a plumbing issue. Something is not connected correctly.
- john