03-24-2020 05:09 PM
Hi there,
I have got a custom made board equiped with BMA456 sensor.
Following guide found on github I could bring the sensor up over I2C interface: https://github.com/BoschSensortec/BMA456-Sensor-API;
My issue is that having basic communication working, no (any-/no-motions) interrupts are generated by sensor IC.
Both interrupt status register 0 & 1 stay zero all ther time regardless how threshold and duration are set up.
I wonder what could be the reason for missing interrupts.
Here is the code snippet used to initialise and test the interrupt generation.
I attached also the traces obtained during one of the test runs.
Is anything that I am doing wrong there?
uint16_t BMA456::sensor_bma456_init(void)
{
uint16_t rslt = BMA4_OK;
this->m_AccelDev.dev_addr = BMA4_I2C_ADDR_SECONDARY;
this->m_AccelDev.interface = BMA4_I2C_INTERFACE;
this->m_AccelDev.bus_read = &BMA456::bma4_read_wrapper;
this->m_AccelDev.bus_write = &BMA456::bma4_write_wrapper;
this->m_AccelDev.delay = &BMA456::bma4_udelay;
this->m_AccelDev.read_write_len = 8;
this->m_AccelDev.resolution = 12;
this->m_AccelDev.feature_len = BMA456_FEATURE_SIZE;
/* a. Reading the chip id. */
rslt |= bma456_init(&this->m_AccelDev);
/* b. Performing initialisation sequence.
c. Checking the correct status of the initialisation sequence.
*/
rslt |= bma456_write_config_file(&this->m_AccelDev);
#if 0
{
uint8_t cmd = 0xB6;
bma4_set_command_register(&cmd, &this->m_AccelDev); // reset device
}
#endif
osDelay(1); // wait for POR finish
rslt |= bma4_set_accel_enable(BMA4_ENABLE, &this->m_AccelDev);
rslt |= bma456_write_config_file(&this->m_AccelDev);
{
uint16_t int_status = 0u;
uint16_t rc = BMA4_OK;
rc |= bma4_read_int_status(&int_status, &this->m_AccelDev);
/* Declare a no/any-motion interrupt configuration structure */
bma456_any_no_mot_config any_mot_confg;
bma456_any_no_mot_config no_mot_confg;
rc |= bma456_get_any_mot_config(&any_mot_confg, &this->m_AccelDev);
if (!rc) {
printf("\n=== Get any-motion configuration successful === \n");
printf("axis_en = %x\n", any_mot_confg.axes_en);
printf("duration = %x\n", any_mot_confg.duration);
printf("threshold = %x\n", any_mot_confg.threshold);
}
rc |= bma456_get_no_mot_config(&no_mot_confg, &this->m_AccelDev);
if (!rc) {
printf("\n=== Get no-motion configuration successful === \n");
printf("axis_en = %x\n", no_mot_confg.axes_en);
printf("duration = %x\n", no_mot_confg.duration);
printf("threshold = %x\n", no_mot_confg.threshold);
}
any_mot_confg.axes_en = BMA456_EN_ALL_AXIS;
any_mot_confg.duration = 5u; /* 5 * 20 ms = 100 ms */
any_mot_confg.threshold = (0xCC); /* 5.11 G, 100 mg */
no_mot_confg.axes_en = BMA456_EN_ALL_AXIS;
no_mot_confg.duration = 5u; /* 5 * 20 ms = 100 ms */
no_mot_confg.threshold = (0xCC); /* 5.11 G, 100 mg */
rc |= bma456_set_any_mot_config(&any_mot_confg, &this->m_AccelDev);
if (!rc) {
printf("\n=== Set any-motion configuration successful === \n");
printf("axis_en = %x\n", any_mot_confg.axes_en);
printf("duration = %x\n", any_mot_confg.duration);
printf("threshold = %x\n", any_mot_confg.threshold);
}
rc |= bma456_set_no_mot_config(&no_mot_confg, &this->m_AccelDev);
if (!rc) {
printf("\n=== Set no-motion configuration successful === \n");
printf("axis_en = %x\n", no_mot_confg.axes_en);
printf("duration = %x\n", no_mot_confg.duration);
printf("threshold = %x\n", no_mot_confg.threshold);
}
{
struct bma4_int_pin_config int_config;
/* Configure INT1 pin */
int_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
int_config.lvl = BMA4_ACTIVE_LOW;
int_config.od = BMA4_PUSH_PULL;
int_config.output_en = BMA4_OUTPUT_ENABLE;
int_config.input_en = BMA4_INPUT_DISABLE;
rc |= bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &this->m_AccelDev);
}
rc |= bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_ANY_MOT_INT, BMA4_ENABLE, &this->m_AccelDev);
rc |= bma456_map_interrupt(BMA4_INTR2_MAP, BMA456_NO_MOT_INT, BMA4_ENABLE, &this->m_AccelDev);
{
volatile bool trap = true;
printf("Shake the sensor in any direction\n");
while (trap) {
/* Read the interrupt status */
rc |= bma4_read_int_status(&int_status, &this->m_AccelDev);
if (rslt == BMA4_OK) {
/* check if any/no motion interrupt is triggered */
if (int_status) {
printf("Any-/No-Motion interrupt occurred := %lu\n", int_status);
break;
}
else {
bma4_accel sens_data;
rc |= bma4_read_accel_xyz(&sens_data, &this->m_AccelDev);
printf("X := %i, Y := %i, Z := %i\n", sens_data.x, sens_data.y, sens_data.z);
}
}
int_status = 0;
udelay(200u);
}
}
}
return rslt;
}
Solved! Go to Solution.
03-27-2020 06:18 PM
I found what was missing!
It seems to be that "soft-reset" command is doing a bit more, than simple reset.
Issuing soft-reset at the place where that code was remmed out by preprocessor directive made my day.
04-03-2020 09:47 AM
Thanks for your attention on our products and glad to hear you solve the problem.If still have questions,please come to community and contact us.