07-21-2021 09:40 PM
Hi,
We are using an STM32 and downloaded drivers from the Bosch website for the BMA456 accelerometer. We are using I2C with address 0x18 for the device.
Using the function in the API "bma4_perform_accel_selftest" returns the error code "BMA4_SELFTEST_DIFF_X_Y_AND_Z_AXIS_FAILED" when we use it, while reading from the accelerometer fifo during regular device operation gives us reasonable values indicating that things are working..
Before calling this function, we execute the following to initialize:
uint8_t addr = BMA4_I2C_ADDR_PRIMARY;
dev->intf_ptr = &addr;
dev->intf = BMA4_I2C_INTF;
dev->bus_read = user_i2c_read;
dev->bus_write = user_i2c_write;
dev->delay_us = user_delay_us;
dev->chip_id = BMA456_CHIP_ID;
dev->variant = BMA45X_VARIANT;
dev->resolution = BMA4_16_BIT_RESOLUTION;
int8_t rslt;
bma456_init(dev);
// Then call self test like so:
bma4_perform_accel_selftest(&rslt, dev);
bma4_soft_reset(dev);
-------------------------------------------------------------------------------------------------------------
Is there something we are doing incorrect in the procedure to run the test? We have not been able to figure out how to run a successful self test and all the connections to the device are good.
Thanks,
Alex P
Solved! Go to Solution.
07-22-2021 03:39 AM
Hello microfactory,
Before you do selftest, it is better to do soft reset and delay 200 ms.
/* Triggers a soft reset */
rslt = bma4_soft_reset(dev);
dev->delay_us(BMA4_MS_TO_US(200), dev->intf_ptr);
07-23-2021 04:57 PM
Thanks for the reply, I have made the change you suggested and received the following message now when running the test:
"BMA4_SELFTEST_FAIL or BMA4_SELFTEST_DIFF_X_AXIS_FAILED"
I have gotten this message on multiple devices, which I suspect means there's something else I am not doing in this block...
Occasionally the reset addition causes the program to hang..
Code:
uint8_t addr = BMA4_I2C_ADDR_PRIMARY;
dev->intf_ptr = &addr;
dev->intf = BMA4_I2C_INTF;
dev->bus_read = user_i2c_read;
dev->bus_write = user_i2c_write;
dev->delay_us = user_delay_us;
dev->chip_id = BMA456_CHIP_ID;
dev->variant = BMA45X_VARIANT;
dev->resolution = BMA4_16_BIT_RESOLUTION;
int8_t rslt;
bma456_init(dev);
/* Triggers a soft reset */
rslt = bma4_soft_reset(dev);
dev->delay_us(BMA4_MS_TO_US(200), dev->intf_ptr);
bma4_perform_accel_selftest(&rslt, dev);
bma4_soft_reset(dev);
buffer[2] = *((uint8_t *)&rslt);
08-05-2021 09:01 AM
08-06-2021 07:04 PM
Thanks BSTRobin, I have added the changes and configuration procedure you provided and finally got the self-test feature to work!
On our end, we had unfortunately incorrectly configured the delay_us function which solved the issue after going through the above configuration.
- Microfactory Co-op