cancel
Showing results for 
Search instead for 
Did you mean: 

The device resets and stops responding when PWR_EN is raised high

Rituraj
Senior

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. 

3 REPLIES 3
John E KVAM
ST Employee

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


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
Rituraj
Senior

I tried debugging and the used &&0 with a few values so the device can atleast start working.

while debugging I came across :

do {
status |= RdMulti(&(p_dev->platform), address,
p_dev->temp_buffer, size);
status |= WaitMs(&(p_dev->platform), 10);
 
if(timeout >= (uint8_t)200) /* 2s timeout */
{
status |= (uint8_t)VL53L8CX_STATUS_TIMEOUT_ERROR;
break;
}else if((size >= (uint8_t)4) 
                         && (p_dev->temp_buffer[2] >= (uint8_t)0x7f))
{
status |= VL53L8CX_MCU_ERROR;
break;
}
else
{
timeout++;
}
}while ((p_dev->temp_buffer[pos] & mask) != 0x38);
 
return status;
}
This is part of the function 
 _vl53l8cx_poll_for_answer(
VL53L8CX_Configuration *p_dev,
uint8_t size,
uint8_t pos,
uint16_t address,
uint8_t mask,
uint8_t expected_value)
inside the vl53l8cx_api.c
 
The device gets stuck into this loop and doesn't get initialized.
 
Also I didn't find any  CUSTOM_RANGING_INSTANCES_NBR declaration is cube mx.
John E KVAM
ST Employee

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

 


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.