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: What is correct sequence of BMA423 driver commands for initialization? Is it just: rslt |= bma423_init(&bma423); rslt |= bma423_write_config_file(&bma423); What is correct sequence of BMA423 driver commands for enabling Step-counter feature? Is it just: rslt |= bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &bma423); What is correct sequence of BMA423 driver commands for enabling Any-motion feature? Is it just: bma423_anymotion_enable_axis(BMA423_Z_AXIS_EN, &bma423); OR bma423_feature_enable(BMA423_ANY_MOTION, BMA4_ENABLE, &bma423); BOTH? What is correct sequence of BMA423 driver commands for enabling and setting up Interrupt triggered by Any-motion feature? For enabling: bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT, BMA4_ENABLE, &bma423); For setting up Intterupt: 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; bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &bma423); How should I set int pin when I need it to be High while no interrupt is triggered and for Low when it is triggered? Correcponding pin in MCU is set to Input, internal Pullup, Interrupt Negative Edge. 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);
... View more