Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMA456 Uable to get any of the any/no motion or tap interrupts to give a response.

    BMA456 Uable to get any of the any/no motion or tap interrupts to give a response.

    DalesLandnet
    Member

    I have to assume I am doing something wrong, but I have been working with the Bosch sensor applications application (AN, H, MM,W) in the context Arduino ESP32. I have no issues in configuring and  reading raw data data but I am unable to get any response other than  zero from any of bma456xxx_read_int_status() functions. There do appear to be various topics that seem to relate to this but nothing has lead anywhere th will help?

    6 REPLIES 6

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your inquiry.

    Please see the attached "How to test BMA456MM any-motion and no-motion interrupt.pdf" for more information. You can adapt the example to your ESP32 platform.

    Thanks.

    Thank you for your response, and it is good to see a recent document on the subject. Unfortunately  it odes not add anything to what is already available  and does not help getting to the bottom of my issue. I have made the changes to support the implentation on the ESP32. I am not encountering any errors being reported in communication with the BMA456 and the ESP32. I am able to configure to get the raw  accelerometer data and  temperature  as well as being able to configure the INT1 pin to get a data ready indication.

    Configuring to use a Feature Interrupt has not raised any errors but I do not see any Interrupt status event being generated for Any Motion ,No Motion, or tap  configutation.

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    That document shows how COINES example code configures BMA456 for any-motion and no-motion interrupt. You can then check your ESP32 code if there is anything missing. If possible, please share your ESP32 code about BMA456 initialization and interrupt configuration. We may be able to look into your code to find out the root cause.

    Thanks.

    I have configured the  no_motion example  of BMA456_an application for ESP32 on arduino. This application runs without generating any errors during set up or in the loop. The code is given below:

     

    #include <Wire.h>
    
    #include "Arduino.h"
    #include "arduino_bma456.h"
    
    #include "bma456_an.h"
    //#include "common.h"
    //#include "coines.h"
    struct bma4_dev bma = { 0 };
    /******************************************************************************/
    /*!           Static Function Declaration                                     */
    
    /*!
     *  @brief This internal API is used to get any-motion configurations.
     *
     *  @param[in] bma       : Structure instance of bma4_dev.
     *
     *  @return Status of execution.
     */
    static int8_t get_any_no_mot_config(struct bma4_dev *bma);
    void bma4_error_codes_print_result(const char api_name[], int8_t rslt)
    {
       if (rslt != BMA4_OK)
       {
          Serial.print(String(api_name).c_str());
          Serial.print("\tError  [");
          Serial.print(rslt);
          if (rslt == BMA4_E_NULL_PTR)
          {
             Serial.println("] : Null pointer");
          }
          else if (rslt == BMA4_E_COM_FAIL)
          {
             Serial.println("] : Communication failure");
          }
          else if (rslt == BMA4_E_CONFIG_STREAM_ERROR)
          {
             Serial.println("] : Invalid configuration stream");
          }
          else if (rslt == BMA4_E_SELF_TEST_FAIL)
          {
             Serial.println("] : Self test failed");
          }
          else if (rslt == BMA4_E_INVALID_SENSOR)
          {
             Serial.println("] : Device not found");
          }
          else if (rslt == BMA4_E_OUT_OF_RANGE)
          {
             Serial.println("] : Out of Range");
          }
          else if (rslt == BMA4_E_AVG_MODE_INVALID_CONF)
          {
             Serial.println("] : Invalid bandwidth and ODR combination in Accel Averaging mode");
          }
          else
          {
             /* For more error codes refer "*_defs.h" */
             Serial.println("] : Unknown error code");
          }
       }
    }
    
    static uint16_t bma_i2c_write(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
    {
       Wire.beginTransmission(addr);
       Wire.write(reg);
       for (uint16_t i = 0; i < len; i++)
       {
          Wire.write(data[i]);
       }
       Wire.endTransmission();
    
       return 0;
    }
    
    static uint16_t bma_i2c_read(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
    {
       uint16_t i = 0;
    
       Wire.beginTransmission(addr);
       Wire.write(reg);
       Wire.endTransmission();
    
       Wire.requestFrom((int16_t) addr, len);
       while (Wire.available())
       {
          data[i++] = Wire.read();
       }
    
       return 0;
    }
    
    static void bma_delay_ms(uint32_t ms)
    {
       delay(ms);
    }
    static void bma_delay_us(uint32_t us)
    {
       delayMicroseconds(us);
    }
    /******************************************************************************/
    /*!            Functions                                                      */
    
    /* This function starts the execution of program. */
    void setup(void)
    {
       /* Variable to store the status of API */
       int8_t rslt;
    
       /* Sensor initialization configuration */
    
       /* Variable to store any/no-motion interrupt status */
       uint16_t int_status = 0;
    
       Serial.begin(115200);
    
       Serial.println("\nInitialising");
       Wire.begin(27, 26);
       bma.dev_addr = BMA4_I2C_ADDR_PRIMARY;
       bma.interface = BMA4_I2C_INTERFACE;
       bma.intf = BMA4_I2C_INTF;
       bma.bus_read = bma_i2c_read;
       bma.bus_write = bma_i2c_write;
       bma.delay = bma_delay_ms;
       bma.delay_us = bma_delay_us;
       bma.read_write_len = 8;
    
       /* Sensor initialization */
       rslt = bma456_an_init(&bma);
       bma4_error_codes_print_result("bma456_an_init status", rslt);
    
       /* Upload the configuration file to enable the features of the sensor. */
       rslt = bma456_an_write_config_file(&bma);
       bma4_error_codes_print_result("bma456_an_write_config status", rslt);
    
       /* Enable the accelerometer */
       rslt = bma4_set_accel_enable(BMA4_ENABLE, &bma);
       bma4_error_codes_print_result("bma4_set_accel_enable status", rslt);
    
       /* Map the interrupt 1 for no-motion */
       rslt = bma456_an_map_interrupt(BMA4_INTR1_MAP, BMA456_AN_NO_MOT_INT, BMA4_ENABLE, &bma);
       bma4_error_codes_print_result("bma456_an_map_interrupt status", rslt);
    
       /* Get no-motion configurations */
       rslt = get_any_no_mot_config(&bma);
       bma4_error_codes_print_result("get_any_no_mot_config status", rslt);
    
    
       Serial.println("Do not shake the board for no-motion interrupt");
    }
    
    void loop(void)
    {
       int8_t rslt;
       uint16_t int_status = 0;
       /* Read interrupt status */
       rslt = bma456_an_read_int_status(&int_status, &bma);
       bma4_error_codes_print_result("bma456_an_read_int_status", rslt);
    
       if (rslt == BMA4_OK)
       {
           /* Enters only if the obtained interrupt is no-motion */
           if (int_status & BMA456_AN_NO_MOT_INT)
           {
               printf("No-motion interrupt occurred\n");
           }
       }
    }
    
    /*!
     *  @brief This internal API is used to get any-motion configurations.
     */
    static int8_t get_any_no_mot_config(struct bma4_dev *bma)
    {
       /* Variable to store the status of API */
       int8_t rslt;
    
       /*! Structure to define any/no-motion configurations */
       struct bma456_an_any_no_mot_config any_no_mot = { 0 };
    
       /* Getting any-motion configuration to get default configuration */
       rslt = bma456_an_get_any_mot_config(&any_no_mot, bma);
       bma4_error_codes_print_result("bma456_an_get_any_mot_config status", rslt);
    
       if (rslt == BMA4_OK)
       {
          /*
           * Set the slope threshold:
           *  Interrupt will be generated if the slope of all the axis exceeds the threshold (1 bit = 0.48mG)
           */
          any_no_mot.threshold = 10;
    
          /*
           * Set the duration for any-motion interrupt:
           *  Duration defines the number of consecutive data points for which threshold condition must be true(1
           * bit =
           * 20ms)
           */
          any_no_mot.duration = 4;
    
          /* Enabling X, Y, and Z axis for Any-motion feature */
          any_no_mot.axes_en = BMA456_AN_EN_ALL_AXIS;
    
          /* Like threshold and duration, we can also change the config of int_bhvr and slope */
    
          /* Set the threshold and duration configuration */
          rslt = bma456_an_set_any_mot_config(&any_no_mot, bma);
          bma4_error_codes_print_result("bma456_an_set_any_mot_config status", rslt);
       }
    
       return rslt;
    }

     

    Please the serial output when the application  runs:-

    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

    configsip: 0, SPIWP:0xee

    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

    mode:DIO, clock div:1

    load:0x3fff0018,len:4

    load:0x3fff001c,len:1044

    load:0x40078000,len:10124

    load:0x40080400,len:5856

    entry 0x400806a8

     

    Initialising

    Do not shake the board for no-motion interrupt

     

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist