Bosch Sensortec Community

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

    BMA456 Tap Interrupts

    BMA456 Tap Interrupts

    Weaver
    Member

    Hi, 
    I'm trying to access the tap interrupts of the BMA456, but am running into some issues. I am largely using the APIs found here.

    I can successful configure the board to output accelerometer data using the accelerometer example (this utilises the BMA4_DATA_RDY_INT interrupt). However, I recieve no triggers when I attempt to poll the interrupts for either single or double taps. I suspect that there is a fairly trivial issue in my configuration or my order of operations that I've missed in the documentation. I've included the important code from test function below (without the error catching functions).

    Any help would be greatly appreciated!

    Cheers,

    Michael.

     

    int8_t rslt = BMA4_OK;
    uint16_t int_status = 0;
    uint8_t iteration = 10;
    
    spi_init(clk, miso, mosi, ss);
    
    bma.intf           = BMA4_SPI_INTF;
    bma.bus_read       = spi_read;
    bma.bus_write      = spi_write;
    bma.intf_ptr       = &dev_addr;  //  Assign device address to interface pointer
    bma.delay_us       = delay_us;
    bma.read_write_len = 8;
    bma.resolution     = 16;
    bma.feature_len    = BMA456_FEATURE_SIZE;
    bma.variant        = BMA45X_VARIANT;
    
    // Verify chip ID
    rslt |= bma456_init(&bma);
    
    // Configuration
    rslt |= bma456_write_config_file(&bma);
    
    // Accelerometer 
    rslt |= bma4_set_accel_enable(BMA4_ENABLE, &bma);
    
    // Interrupts
    rslt |= bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_SINGLE_TAP_INT | BMA456_DOUBLE_TAP_INT, BMA4_ENABLE, &bma);
    
    // Enabling features
    rslt = bma456_feature_enable((BMA456_SINGLE_TAP | BMA456_DOUBLE_TAP), BMA4_ENABLE, &bma);
    
    //Do Single or Double Tap the board
    while (1)
    {
    	/* Read interrupt status */
    	rslt = bma456_read_int_status(&int_status, &bma);
    	bma4_error_codes_print_result("bma456_read_int_status", rslt);
    
    	/* Enters only if the obtained interrupt is single-tap */
    	if ((rslt == BMA4_OK) && (int_status & BMA456_SINGLE_TAP_INT))
    	{
    		printf("Single tap interrupt occurred\n");
    		iteration--;
    	}
    
    	/* Enters only if the obtained interrupt is double-tap */
    	else if ((rslt == BMA4_OK) && (int_status & BMA456_DOUBLE_TAP_INT))
    	{
    		printf("Double tap interrupt occurred\n");
    		iteration--;
    	}
    
    	int_status = 0;
    
    	/* Break out of the loop when iteration has reached zero */
    	if (iteration == 0)
    	{
    		printf("Iterations are done. Exiting !");
    		break;
    	}
    }

     

     

    4 REPLIES 4

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Weaver,

    There was TAP example code for your reference, this example code show receiving TAP event via HW interrupt.
    Open the following macro define and use at least 200 Hz ODR.

    #define TAP

    Hi BSTRobin,
    Thanks for getting back to me, I'll give a try and let you know how I go.

    Cheers,

    Michael.

    Hi,

    Thanks! I got the BMA456 tap functions running based on the example you provided me.


    I know when I was getting start in writing this, I found some aspects a little slow to get going so I thought I'd include my test code as an example, in case it helps anyone. It is designed to run on an ESP32 with the arduino framework, communicates over SPI, use interrupts and largely comprises chunks from the Bosch examples. 

    Cheers,

    Michael

     

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Weaver,

    Good. Thanks for your kindly sharing in community.

    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