2023-05-21 04:44 AM
Hello, I'm using the LoRaWAN-End-Node example on an STM32WL55JC MCU to drive the VL53L4CD sensor.
I would like to use the interrupt pin to get the data from the sensor.
what is happening is that once __WFI() in the getting data subroutine is executed (code below), the LoRaWAN cycle seems to be broken.
How can i embed the "Sleep until an interrupt" in the LoRaWAN cycle?
Thank you...
void VL53_data_interrupt(cData_t *sensordata)
{
// static uint8_t i = 0;
while (meas_count < NUM_MEASUREMENTS)
{
__WFI(); // Wait for interrupt
if (IntCount != 0)
{
IntCount = 0;
/* (Mandatory) Clear HW interrupt to restart measurements */
VL53L4CD_ClearInterrupt(sensordata->Vl53_Dev);
/* Read measured distance. RangeStatus = 0 means valid data */
VL53L4CD_GetResult(sensordata->Vl53_Dev, &(sensordata->VL53_Res));
if (sensordata->VL53_Res.range_status == 0)
{
Arr_dist_mm[meas_count] = sensordata->VL53_Res.distance_mm;
// printf("Distance = %3u mm\n", results.distance_mm);
Acc_Dist += sensordata->VL53_Res.distance_mm;
meas_count++;
}
}
}
uint32_t Av_Distance = Acc_Dist / NUM_MEASUREMENTS;
printf("Average distance = %5lu mm\n", Av_Distance);
meas_count = 0;
Acc_Dist = 0;
}
2023-05-21 09:01 AM
You're trying to do this in an INTERRUPT ??
Need to come up with a method that does this statefully
2023-05-25 03:50 AM
The Interrupt is working fine until the Stop-Mode is enabled then a strange behavior starts to happen:
As the XShut(Interrupt-Pin) gets triggered when the MCU 1st stars.
I can go with the busy-wait solution but I'm trying to optimize the power as much as possible.