04-16-2020 01:37 PM
Hello,
I am currently trying to enable Step-counter and Any-motion feature on BMA423.
Application note is saying that for enabling:
Step-counter I need to just set FEATURE_IN.step_counter.settings_26.en_counter - done by bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &bma423).
Any-motion I need to set one of the axes in FEATURE_IN.any_motion.settings_2.x_en/y_en/z_en - done by bma423_anymotion_enable_axis(BMA423_Z_AXIS_EN, &bma423).
Tried that and neither works.
My main questions are:
I've tried different combinations of code sequences, but none works.
Code below prints BMA4_OK, so no errors occurred during writing into registers.
Can anyone see what I am doing wrong? Please point me in the right direction. I will be glad for any advice or help.
Thank you very much.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include "bma423.h"
struct bma4_dev bma423;
void BMA423_initialization()
{
uint16_t rslt = BMA4_OK;
struct bma4_int_pin_config int_config;
struct bma423_anymotion_config anymotion_conf;
bma423.interface = BMA4_SPI_INTERFACE;
bma423.bus_read = BMA423_reg_read;
bma423.bus_write = BMA423_reg_write;
bma423.delay = delay_ms;
bma423.read_write_len = 64;
rslt |= bma423_init(&bma423);
rslt |= bma423_write_config_file(&bma423);
// Tried if enabling and setting the accel would help. Didnt
// rslt |= bma4_set_accel_enable(BMA4_ENABLE, &bma423);
// /* Declare an accelerometer configuration structure */
// struct bma4_accel_config accel_conf;
//
// /* Assign the desired settings */
// accel_conf.odr = BMA4_OUTPUT_DATA_RATE_1600HZ;
// accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
// accel_conf.range = BMA4_ACCEL_RANGE_4G;
// accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;
//
// /* Set the configuration */
// rslt |= bma4_set_accel_config(&accel_conf, &bma423);
rslt |= bma423_select_platform(BMA423_WRIST_CONFIG, &bma423);
rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT, BMA4_ENABLE, &bma423);
/* Configure INT1 pin */
int_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
int_config.lvl = BMA4_ACTIVE_HIGH;
int_config.od = BMA4_PUSH_PULL;
int_config.output_en = BMA4_OUTPUT_ENABLE;
int_config.input_en = BMA4_INPUT_DISABLE;
rslt |= bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &bma423);
anymotion_conf.threshold = 0xAA; // 0xAA(170) 83mg; 0xCC(204) 100mg
anymotion_conf.duration = 1; // X*20ms
rslt |= bma423_set_any_motion_config(&anymotion_conf, &bma423);
rslt |= bma423_anymotion_enable_axis(BMA423_Z_AXIS_EN, &bma423);
rslt |= bma423_feature_enable(BMA423_ANY_MOTION, BMA4_ENABLE, &bma423);
rslt |= bma423_reset_step_counter(&bma423);
rslt |= bma423_step_detector_enable(BMA4_ENABLE, &bma423);
rslt |= bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &bma423);
print_rslt(rslt, line_offset);
line_offset++;
if(rslt != BMA4_OK) {
while(1);
}
}
For gettings Step-counter values I use:
uint32_t step_count = 0;
bma423_step_counter_output(&step_count, &bma423);
Display_print1(dispHandle, line_offset, 0, "Step count: %ld", (uint16_t)step_count);
Solved! Go to Solution.
04-17-2020 01:07 AM
You steps in item 1 - 4 are both correct.
For item 5, you need to select int_config.lvl = BMA4_ACTIVE_LOW, then the pin will keep high when interrupt is not generated.
Your code looks good, just one thing missing: after power on, sensor is in sleep mode. you need change the power mode of sensor to normal mode first.
If sensor is not working, no data sample generated, then there obviously no interrupt generated.
04-18-2020 06:36 PM - edited 04-18-2020 06:39 PM
Thank you for your response.
I am not sure what do you mean by Normal power mode, but I changed power mode to Performance mode with:
ACC_CONF.acc_perf_mode = 0b1 (accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;)
PWR_CTRL.acc_en = 0b1 (bma4_set_accel_enable(BMA4_ENABLE, &bma423);)
This however did not help - I still can not get any Interrupt when I shake with the sensor (checking witch osciloscope and by reading int_status register) and I can not get step_count different from zero.
Would you check my modified code below for any other mistake, please? Thank you again for helping me.
04-22-2020 10:30 AM
SELF REPLY
Thanks again Vincent for pointing out, that I did not set power mode. It was the main issue.
Code below enables step-counting and any-motion functions properly. For testing step_counter you can just wave with the sensor back and forth for at least 10 times.
bma423.c rev 1.1.4
bma4.c rev 2.1.9
04-25-2020 01:49 AM
Did you download the configure string of BMA423 during initialization?
without this step, the interrupt is not suppose to work