Bosch Sensortec Community

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

    BMA456 not firing interrupts

    BMA456 not firing interrupts

    hermallorn
    New Poster

    Hi, I am trying to get the ANY_MOTION/NO_MOTION feature working, but i am not able to get any interrupts from the BMA456, either from the pin or the register.

    Everything looks fine, i can get accel data, the sensor returns no error. I have added a picture of the debuger with all variables values.

    The code:

    static void SPI_BMA456_Task_Config(void)
    {
    	switch (SPI_BMA456_appData.BMA456_phase_config)
    	{
    		case BMA456_RESET:
    			// fct d'interface R/W SPI (avec attente)
    			BMA456_dev.bus_read=bma_SPI_read;		
    			BMA456_dev.bus_write=bma_SPI_write;
    			BMA456_dev.delay= bma_delay_ms;
    			
    			// init dev et lit chip id
    			bma456_init(&BMA456_dev); 
    			SPI_BMA456_appData.BMA456_phase_config=BMA456_ID;
    		break;
    
    		// init et lecture id composant 0x16
    		case BMA456_ID:
    		// chip id lu : vérif si ok, et commence config si oui
    			if (BMA456_dev.chip_id==BMA456_CHIP_ID)
    			{
    				// délai 500µs
    				TMR3_StartTimer(TIMER3_BMA456_512uS, 1);
    				SPI_BMA456_appData.BMA456_phase_config=BMA456_WAIT500;
    			}
    		break;
    		
    		// délai avant envoi config
    		case BMA456_WAIT500:
    			// si fin délai, suite
    			if (timer3_fini())
    			{
    				SPI_BMA456_appData.BMA456_phase_config=BMA456_FEATURES;
    			}
    			
    		break;
    		
    		// envoie le fichier de config
    		case BMA456_FEATURES:
    			// disable power, envoie bloc de config, enable power save, lit status 2A, vérif OK, lit adr config 
    			if (bma456_write_config_file(&BMA456_dev)==BMA4_OK)
    				SPI_BMA456_appData.BMA456_phase_config=BMA456_CONFIG;
    			else
    				SPI_BMA456_appData.BMA456_phase_config=BMA456_ID;		// délai + nouvel essai
    		break;
    		
    		// config fonctionnement 
    		case BMA456_CONFIG:
    		{
                bma4_set_advance_power_save(BMA4_DISABLE,	&BMA456_dev);
    /* moved to BMA4.c before rslt|=bma4_write_regs(BMA4_INIT_CTRL_ADDR, &config_load, 1, dev);
     * otherwise no_motion parameter not changed
    //------------------------------------------------------------------------------
                if (BMA4_OK!=bma4_set_interrupt_mode(BMA4_LATCH_MODE, &BMA456_dev)) DEBUG_MSG("bma4_set_interrupt_mode failed",DBGmask_BMA456);
    			if (BMA4_OK!=bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_ANY_NO_MOTION_INT, BMA4_ENABLE, &BMA456_dev)) DEBUG_MSG("bma456_map_interrupt1 failed",DBGmask_BMA456);
    			if (BMA4_OK!=bma456_map_interrupt(BMA4_INTR2_MAP, BMA4_FIFO_WM_INT, BMA4_ENABLE, &BMA456_dev)) DEBUG_MSG("bma456_map_interrupt2 failed",DBGmask_BMA456);
    
                //3) config Interrupts ports
                struct bma4_int_pin_config int1_config;
                int1_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
                int1_config.lvl = BMA4_ACTIVE_LOW;//BMA4_ACTIVE_HIGH;//BMA4_ACTIVE_LOW
                int1_config.od = BMA4_PUSH_PULL;
                int1_config.output_en = BMA4_OUTPUT_ENABLE;
                int1_config.input_en = BMA4_INPUT_DISABLE;
    			if (BMA4_OK!=bma4_set_int_pin_config(&int1_config,BMA4_INTR1_MAP, &BMA456_dev)) DEBUG_MSG("bma4_set_int1_pin_config failed",DBGmask_BMA456);
    
                struct bma4_int_pin_config int2_config;
                int2_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
                int2_config.lvl = BMA4_ACTIVE_HIGH;
                int2_config.od = BMA4_PUSH_PULL;
                int2_config.output_en = BMA4_OUTPUT_ENABLE;
                int2_config.input_en = BMA4_INPUT_DISABLE;
    			if (BMA4_OK!=bma4_set_int_pin_config(&int2_config,BMA4_INTR2_MAP, &BMA456_dev)) DEBUG_MSG("bma4_set_int2_pin_config failed",DBGmask_BMA456);
    //------------------------------------------------------------------------------
                struct bma456_anymotion_config nomotion_conf;
                nomotion_conf.duration = 5;//250;//250*20ms=5sec
                nomotion_conf.threshold = 0xAA;//default 0.083g
                nomotion_conf.nomotion_sel = 1;//set when NO_MOTION enabled
    			if (BMA4_OK!=bma456_set_any_motion_config(&nomotion_conf, &BMA456_dev)) DEBUG_MSG("bma456_set_any_motion_config failed",DBGmask_BMA456);
    //------------------------------------------------------------------------------
    			struct bma4_accel_config accel_conf;
    			// valeurs dans BMA4_defs.h
    			accel_conf.odr=BMA4_OUTPUT_DATA_RATE_200HZ;				// Output data rate in Hz 
    			accel_conf.bandwidth=BMA4_ACCEL_OSR4_AVG1;				// Bandwidth parameter, determines filter configuration 
    			accel_conf.perf_mode=BMA4_CONTINUOUS_MODE;				// Filter performance mode 
    			accel_conf.range=BMA4_ACCEL_RANGE_4G;                   // G-range 
    			if (BMA4_OK!=bma4_set_accel_config(&accel_conf, &BMA456_dev)) DEBUG_MSG("bma4_set_accel_config failed",DBGmask_BMA456);			
    //------------------------------------------------------------------------------
    			// enable composant
    			if (BMA4_OK!=bma4_set_accel_enable(BMA4_ENABLE, &BMA456_dev)) DEBUG_MSG("bma4_set_accel_enable failed",DBGmask_BMA456);
    			if (BMA4_OK!=bma456_anymotion_enable_axis(BMA456_ALL_AXIS_EN, &BMA456_dev)) DEBUG_MSG("bma456_anymotion_enable_axis failed",DBGmask_BMA456);
                if (BMA4_OK!=bma456_feature_enable(BMA456_NO_MOTION, BMA4_ENABLE, &BMA456_dev)) DEBUG_MSG("bma456_feature_enable2 failed",DBGmask_BMA456);
    //------------------------------------------------------------------------------
    */			            
    			// check config
    			uint8_t interrupt_mode_test;
                if (BMA4_OK!=bma4_get_interrupt_mode(&interrupt_mode_test, &BMA456_dev)) DEBUG_MSG("bma4_set_interrupt_mode failed",DBGmask_BMA456);
    
                struct bma4_int_pin_config int1_config_test;
    			if (BMA4_OK!=bma4_get_int_pin_config(&int1_config_test,BMA4_INTR1_MAP, &BMA456_dev)) DEBUG_MSG("bma4_get_int1_pin_config failed",DBGmask_BMA456);
    
                struct bma4_int_pin_config int2_config_test;
    			if (BMA4_OK!=bma4_get_int_pin_config(&int2_config_test,BMA4_INTR2_MAP, &BMA456_dev)) DEBUG_MSG("bma4_get_int2_pin_config failed",DBGmask_BMA456);
    
                struct bma456_anymotion_config nomotion_conf_verif;
                nomotion_conf_verif.duration = 5;//250;//250*20ms=5sec
                nomotion_conf_verif.threshold = 0xAA;//default 0.083g
                nomotion_conf_verif.nomotion_sel = 1;//set when NO_MOTION enabled
                struct bma456_anymotion_config nomotion_conf_read;
    			if (BMA4_OK!=bma456_get_any_motion_config(&nomotion_conf_read, &BMA456_dev)) DEBUG_MSG("bma456_get_any_motion_config failed",DBGmask_BMA456);
    			if ((nomotion_conf_verif.duration!=nomotion_conf_read.duration)|(nomotion_conf_verif.threshold!=nomotion_conf_read.threshold)|(nomotion_conf_verif.nomotion_sel!=nomotion_conf_read.nomotion_sel)) DEBUG_MSG("any_motion_config failed",DBGmask_BMA456);
    
    			struct bma4_accel_config accel_conf_verif;
    			// valeurs dans BMA4_defs.h
    			accel_conf_verif.odr=BMA4_OUTPUT_DATA_RATE_200HZ;				// Output data rate in Hz 
    			accel_conf_verif.bandwidth=BMA4_ACCEL_OSR4_AVG1;				// Bandwidth parameter, determines filter configuration 
    			accel_conf_verif.perf_mode=BMA4_CONTINUOUS_MODE;				// Filter performance mode 
    			accel_conf_verif.range=BMA4_ACCEL_RANGE_4G;                   // G-range 
    			struct bma4_accel_config accel_conf_read;
    			if (BMA4_OK!=bma4_get_accel_config(&accel_conf_read, &BMA456_dev)) DEBUG_MSG("bma4_get_accel_config failed",DBGmask_BMA456);
    			if ((accel_conf_verif.odr!=accel_conf_read.odr)|(accel_conf_verif.bandwidth!=accel_conf_verif.bandwidth)|(accel_conf_verif.perf_mode!=accel_conf_read.perf_mode)|(accel_conf_verif.range!=accel_conf_read.range)) DEBUG_MSG("bma4_set_accel_config failed",DBGmask_BMA456);
    
    			// check enabled composant
    			uint8_t accel_enabled;
                if (BMA4_OK!=bma4_get_accel_enable(&accel_enabled, &BMA456_dev)) DEBUG_MSG("bma4_set_accel_enable failed",DBGmask_BMA456);
                if (accel_enabled==BMA4_ENABLE) DEBUG_MSG("accel enabled",DBGmask_BMA456);
                struct bma456_anymotion_config nomotion_enabled;
    			if (BMA4_OK!=bma456_get_any_motion_config(&nomotion_enabled, &BMA456_dev)) DEBUG_MSG("bma456_get_any_motion_config failed",DBGmask_BMA456);
    			if (1==nomotion_enabled.nomotion_sel) DEBUG_MSG("no_motion enabled",DBGmask_BMA456);
    			
    //***STATUS CHECK***************************************************************            
    			struct bma4_asic_status asic_status_test;
                if (BMA4_OK!=bma4_get_asic_status(&asic_status_test, &BMA456_dev)) DEBUG_MSG("bma4_set_accel_enable failed",DBGmask_BMA456);
                struct bma4_err_reg err_reg_test;
                bma4_get_error_status(&err_reg_test, &BMA456_dev);
                uint8_t *statutus_test;
                bma4_get_status(&statutus_test, &BMA456_dev);
                uint8_t config_stream_status;
                bma4_read_regs(BMA4_INTERNAL_STAT, &config_stream_status, 1, &BMA456_dev);
                uint16_t int_status_test = 0;
                if (BMA4_OK!=bma456_read_int_status(&int_status_test, &BMA456_dev)) DEBUG_MSG("bma456_read_int_status failed",DBGmask_BMA456);
                if (BMA4_OK!=bma456_read_int_status(&int_status_test, &BMA456_dev)) DEBUG_MSG("bma456_read_int_status failed",DBGmask_BMA456);
    //***END STATUS CHECK***********************************************************            
    
                bma4_set_advance_power_save(BMA4_ENABLE,	&BMA456_dev);
    
    			SPI_BMA456_appData.BMA456_phase_config=BMA456_READY;		// prêt pour faire des mesures
      		};
    			
    		break;
    		
    		// fin de config
    		case BMA456_READY:
    		default:	
    		break;
    		
    	}
    }

    Any clues?

    With all my thanks.

     

    EDITED: code cleanup

    2 REPLIES 2

    hermallorn
    New Poster

    handytech
    Community Moderator
    Community Moderator

    Please note that the sample code you linked is for the BMA400 rather than the BMA456. A (soft) reset is typically not necessary, but can be used to restore a known configuration/state to a sensor.

    Regarding BMA456's interrupt not firing, it is not clear why it is not working based on your sample code.  Re-using your configuration for the accelerometer and the no-motion feature, I have written the attached example code. This example successfully runs in COINES (available from our Downloads page, Software tab) and confirms the no-motion interrupt is working by checking the level of the INT1 pin, as well as verifying the interrupt source in the INT_STATUS registers. It prints acceleration data in the console during motion, and a debug message if the no-motion interrupt is triggered.

    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