53L5A1 SimpleRanging example code timeout error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2022-11-23 03:35 AM
I am trying to get the simple ranging example code for the 53L5A1 to work on the WB55RG board but I keep getting a timeout error.
The text output the example code outputs is "L53L5A1_RANGING_SENSOR_Init failed. Check you're using ONLY the center device soldered on the shield, NO satellite shall be connected".
After looking into the exact error I have found out it is caused by the I2C_WaitOnFlagUntilTimeout function in stm32wbxx_hal_i2c.c.
static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Flag, FlagStatus Status,
uint32_t Timeout, uint32_t Tickstart)
{
while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)
{
/* Check for the Timeout */
if (Timeout != HAL_MAX_DELAY)
{
if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
{
hi2c->ErrorCode |= HAL_I2C_ERROR_TIMEOUT;
hi2c->State = HAL_I2C_STATE_READY;
hi2c->Mode = HAL_I2C_MODE_NONE;
/* Process Unlocked */
__HAL_UNLOCK(hi2c);
return HAL_ERROR;
}
}
}
return HAL_OK;
}
The timeout variable is 4096 and it errors when the tickstart goes to 4097.
The stack where to error occurs is
SensorTestProject [STM32 C/C++ Application]
SensorTestProject.elf [cores: 0]
Thread #1 [main] 1 [core: 0] (Suspended : Breakpoint)
I2C_WaitOnFlagUntilTimeout() at stm32wbxx_hal_i2c.c:6,656 0x80056f4
HAL_I2C_Mem_Read() at stm32wbxx_hal_i2c.c:2,536 0x800530e
BSP_I2C1_ReadReg16() at stm32wbxx_nucleo_bus.c:271 0x8000b5c
RdByte() at platform.c:70 0x8003646
VL53L5CX_ReadID() at vl53l5cx.c:217 0x800392e
VL53L5CX_Probe() at 53l5a1_ranging_sensor.c:496 0x80011ca
VL53L5A1_RANGING_SENSOR_Init() at 53l5a1_ranging_sensor.c:79 0x8000f62
MX_53L5A1_SimpleRanging_Init() at app_tof.c:104 0x8008798
MX_TOF_Init() at app_tof.c:73 0x8008770
main() at main.c:95 0x800059e
arm-none-eabi-gdb (10.2.90.20210621)
ST-LINK (ST-LINK GDB server)
In HAL_I2C_Mem_Read() at stm32wbxx_hal_i2c.c the variables are
hi2c I2C_HandleTypeDef * 0x200003cc <hi2c1>
Instance I2C_TypeDef * 0x40005400
Init I2C_InitTypeDef {...}
pBuffPtr uint8_t * 0x2002ff71 ""
XferSize uint16_t 0
XferCount volatile uint16_t 1
XferOptions volatile uint32_t 0
PreviousState volatile uint32_t 0
XferISR HAL_StatusTypeDef (*)(struct __I2C_HandleTypeDef *, uint32_t, uint32_t) 0x0
hdmatx DMA_HandleTypeDef * 0x0
hdmarx DMA_HandleTypeDef * 0x0
Lock HAL_LockTypeDef HAL_UNLOCKED
State volatile HAL_I2C_StateTypeDef HAL_I2C_STATE_READY
Mode volatile HAL_I2C_ModeTypeDef HAL_I2C_MODE_NONE
ErrorCode volatile uint32_t 32
AddrEventCount volatile uint32_t 0
Devaddress volatile uint32_t 0
Memaddress volatile uint32_t 0
DevAddress uint16_t 82
MemAddress uint16_t 0
MemAddSize uint16_t 2
pData uint8_t * 0x2002ff92 ""
Size uint16_t 1
Timeout uint32_t 4096
tickstart uint32_t 4097
In I2C_WaitOnFlagUntilTimeout() at stm32wbxx_hal_i2c.c the variables are
hi2c I2C_HandleTypeDef * 0x200003cc <hi2c1>
Instance I2C_TypeDef * 0x40005400
CR1 volatile uint32_t 1
CR2 volatile uint32_t 16916562
OAR1 volatile uint32_t 32768
OAR2 volatile uint32_t 0
TIMINGR volatile uint32_t 3149624
TIMEOUTR volatile uint32_t 0
ISR volatile uint32_t 32769
ICR volatile uint32_t 0
PECR volatile uint32_t 0
RXDR volatile uint32_t 0
TXDR volatile uint32_t 0
Init I2C_InitTypeDef {...}
pBuffPtr uint8_t * 0x2002ff71 ""
XferSize uint16_t 0
XferCount volatile uint16_t 1
XferOptions volatile uint32_t 0
PreviousState volatile uint32_t 0
XferISR HAL_StatusTypeDef (*)(struct __I2C_HandleTypeDef *, uint32_t, uint32_t) 0x0
hdmatx DMA_HandleTypeDef * 0x0
hdmarx DMA_HandleTypeDef * 0x0
Lock HAL_LockTypeDef HAL_UNLOCKED
State volatile HAL_I2C_StateTypeDef HAL_I2C_STATE_READY
Mode volatile HAL_I2C_ModeTypeDef HAL_I2C_MODE_NONE
ErrorCode volatile uint32_t 32
AddrEventCount volatile uint32_t 0
Devaddress volatile uint32_t 0
Memaddress volatile uint32_t 0
Flag uint32_t 32768
Status FlagStatus SET
Timeout uint32_t 25
Tickstart uint32_t 4097
I have gotten the example code to work on the F401RE board without any issues but I am unable to get it to work with the WB55RG board. I am new to using I2C so I am not sure why it is timing out or how to go about fixing it. Any ideas of what to look for or examples of how to fix it will be greatly appreciated.
- Labels:
-
I2C
-
STM32WB series