Hello! I'm currently working with a BMA423 (accelerometer) and I'm trying to get the interrupt working for the any motion configuration. I'm using the API from your github page and can read out the temperature or xyz values for example. I used the motion example as an example and read the post on the bosch community website to further enhance it. This is the code I'm using:
m_rslt = bma4_interface_selection(&m_bma, BMA42X_VARIANT, i2c);
/* Sensor initialization */
m_rslt = bma423_init(&m_bma);
/* Upload the configuration file to enable the features of the sensor. */
m_rslt = bma423_write_config_file(&m_bma);
/* Enable the accelerometer */
m_rslt = bma4_set_accel_enable(BMA4_ENABLE, &m_bma);
/* Accelerometer Configuration Setting */
/* Output data Rate */
m_accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
/* Gravity range of the sensor (+/- 2G, 4G, 8G, 16G) */
m_accel_conf.range = BMA4_ACCEL_RANGE_16G;
/* Bandwidth configure number of sensor samples required to average
* if value = 2, then 4 samples are averaged
* averaged samples = 2^(val(accel bandwidth))
* Note1 : More info refer datasheets
* Note2 : A higher number of averaged samples will result in a lower noise level of the signal, but
* since the performance power mode phase is increased, the power consumption will also rise.
m_accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
/* Enable the filter performance mode where averaging of samples
* will be done based on above set bandwidth and ODR.
* There are two modes
* 0 -> Averaging samples (Default)
* 1 -> No averaging
* For more info on No Averaging mode refer datasheets.
m_accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;//BMA4_CIC_AVG_MODE;
/* Set the accel configurations */
m_rslt = bma4_set_accel_config(&m_accel_conf, &m_bma);
/* Select the axis for which any/no motion interrupt should be generated */
m_any_no_mot.axes_en = BMA423_EN_ALL_AXIS;
* Set the slope threshold:
* Interrupt will be generated if the slope of all the axis exceeds the threshold (1 bit = 0.48mG)
m_any_no_mot.threshold = 1; <- I tried several options ranging from 1 to 10
* Set the duration for any/no motion interrupt:
* Duration defines the number of consecutive data points for which threshold condition must be true(1 bit = 20ms)
m_any_no_mot.duration = 1; <- I tried several options ranging from 1 to 4
/* Set the threshold, duration and axis enable configuration */
m_rslt = bma423_set_any_mot_config(&m_any_no_mot, &m_bma);
/* Map the interrupt pin with that of any-motion and no-motion interrupts.
* Interrupt will be generated when any or no-motion is recognized.
* BMA423_ANY_MOT_INT seems to be defined incorrectly according to the datasheet. I tried BMA423_ANY_MOT_INT (0x20), but that did not work.
* 0x40 sets the seventh bit on 1, which seems to be the correct value according to the datasheet. I also tried 0xFF to set it al to 1 and tried 0x00 to set it all to 0.
m_rslt = bma423_map_interrupt(BMA4_INTR1_MAP, 0x40, BMA4_ENABLE, &m_bma);
m_int_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
m_int_config.lvl = BMA4_ACTIVE_HIGH;
m_int_config.od = BMA4_PUSH_PULL;
m_int_config.output_en = BMA4_OUTPUT_ENABLE;
m_int_config.input_en = BMA4_INPUT_DISABLE;
m_rslt = bma4_set_int_pin_config(&m_int_config, BMA4_INTR1_MAP, &m_bma);
m_rslt = bma4_set_interrupt_mode(BMA4_LATCH_MODE, &m_bma);
# in a process function:
bma4_read_accel_xyz(&m_sens_data, &m_bma); <- works!
bma4_get_temperature(&temperature, BMA4_DEG, &m_bma); <- works!
m_rslt = bma423_read_int_status(&m_int_status, &m_bma); <- does not work. m_rslt is always 0x00 and m_int_status is also always 0x00. I'm shaking it quite heavily and for several seconds.
I hope someone can help out! Thanks in advance.
Let's do step by step.
1) Please check motion example in github. (No hardware interrupt pin setting)
2) Test in your environment
Interrupt shall be read from BMA423.
3) Add hardware interrupt pin after map interrupt function.
/* INT1 active high, output enable */
int_pin_config.edge_ctrl = 0x00; // 0 = level, 1 = edge
int_pin_config.lvl = 0x01; // 0 = active low, 1 = active high
int_pin_config.od = 0x0; // 0 = push-pull, 1 = open drain
int_pin_config.output_en = 0x01; // 0 = output disabled, 1 = output enabled
int_pin_config.input_en = 0x0; // 0 = input disabled, 1 = input enabled. input used for fifo things
// INT1 active high, pushpull, output enabled
rslt = bma4_set_int_pin_config(&int_pin_config, 0, &bma);
4) Test again ( Hardware interrupt shall connect to MCU pin)
Thanks for your reply! I already tried the sollution on the github page (exact copy), but that does not work unfortunatly. I can still read out xyz value, but the int_status does not change when I just leave it or shake it heavily for quite some time. I also tried this on another board, but it also does not work on that one. Do you have any other idea's?
I think it's more likely hardware issue since my guide was I tested it from my side.
Which hardware are you using it? Are you using our application board?
If not, please check hardware interrupt connection.
Thanks for answering. We are using our own hardware. I also had the feeling that it might be a hardware issue. Yesterday I spend a few hours with our hardware department and measured all the connections. The I2C connections can send their data in a correct manner. Using a scope we can clearly see all the data going in and out. Our interrupt lines are directly connected to the microcontroller and are defined as inputs. The schematic for the BMA423 is as below. The pull up resistors for the I2C lines are drawn somewhere else in the schematic.
Could it be possible that the interrupt is being reset before I can read it out by some other process or signal? Do the interrupts even work with a voltage of 1.8?