2025-11-18 7:40 PM
Hello,
I have been working with a NUCLEO-WBA55CG board and the X-NUCLEO-IKS02A1 expansion board. When running my initialization code, the program execution jumps to the error handler. Using a debugger, I've pinpointed the failure to the ISM330DHCX_Set_Mem_Bank function. The function returns an error status, which triggers my error handling routine. My initial approach was to replicate the project setup described in DataLogTerminal project . This led directly to the failure at ISM330DHCX_Set_Mem_Bank. I have compared my initialization code against the reference implementation in Board Extension IKS02A1 ISM330DHCX_0_Probe function and they appear to be identical.
My Questions:
Here is the code that I added:
/* USER CODE BEGIN Includes */
#include "ism330dhcx.h"
#include "stm32wbaxx_nucleo_bus.h"
/* USER CODE END Includes */
/* USER CODE BEGIN 2 */
MX_MEMS_Init();
/* USER CODE END 2 */
/* USER CODE BEGIN 4 */
static void MX_MEMS_Init(void){
ISM330DHCX_IO_t io_ctx;
io_ctx.Address = ISM330DHCX_I2C_BUS;
io_ctx.BusType = ISM330DHCX_I2C_ADD_H;
io_ctx.Init = BSP_I2C1_Init;
io_ctx.DeInit = BSP_I2C1_DeInit;
io_ctx.ReadReg = BSP_I2C1_ReadReg;
io_ctx.WriteReg = BSP_I2C1_WriteReg;
io_ctx.GetTick = BSP_GetTick;
io_ctx.Delay = HAL_Delay;
int32_t ret = 0;
ISM330DHCX_Object_t imu_sensor;
ret = ISM330DHCX_RegisterBusIO(&imu_sensor, &io_ctx);
if (ret != ISM330DHCX_OK){
Error_Handler();
}
ret = ISM330DHCX_Set_Mem_Bank(&imu_sensor, ISM330DHCX_USER_BANK);
if (ret != ISM330DHCX_OK){
Error_Handler();
}
uint8_t id;
ret = ISM330DHCX_ReadID(&imu_sensor, &id);
if (ret != ISM330DHCX_OK){
Error_Handler();
}
if (id != ISM330DHCX_ID){
Error_Handler();
}
ISM330DHCX_AxesRaw_t axes_raw;
ISM330DHCX_Init(&imu_sensor);
ISM330DHCX_ACC_SetOutputDataRate(&imu_sensor, 26.0f);
ISM330DHCX_ACC_SetFullScale(&imu_sensor, ISM330DHCX_16g);
ISM330DHCX_ACC_GetAxesRaw(&imu_sensor, &axes_raw);
ISM330DHCX_GYRO_SetOutputDataRate(&imu_sensor, 26.0f);
ISM330DHCX_GYRO_SetFullScale(&imu_sensor, ISM330DHCX_4000dps);
ISM330DHCX_GYRO_GetAxesRaw(&imu_sensor, &axes_raw);
ISM330DHCX_ACC_Enable(&imu_sensor);
ISM330DHCX_GYRO_Enable(&imu_sensor);
}
/* USER CODE END 4 */Steps to Reproduce:
Environment: