Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMA425 issue in I2C fast mode (400kbps)

    BMA425 issue in I2C fast mode (400kbps)


    Hi expert, recently i am working on our BLE application platform with BMA425 on broad for motion tracking. At the first i configed MCU I2C as standard mode (100kbps) to connect BMA425 and you know 425 is set as header and powersave mode with FIFO enabled (No irq and watermark used). MCU app will read FIFO data when each time my timer handler is serviced per 10 seconds (BMA425 ODR is 6.25Hz).

    So my logic is when timer handler is running, i disable powersave mode firstly plus a minor delay (1ms), after that i issue the brust read of FIFO data. When 10S FIFO data is ate up, i enable the powersave mode again.  The code is working fine under I2C standard mode. So I change the I2C as fast mode (a.k.a. 400Kbps), the issue is coming then, you know, i still can read FIFO data but I find more time is consumed for completion of FIFO read comparing with standard mode. Typically 50ms in standard mode but 125ms in fast mode. That's weird ryt?  Fast mode I2C will consume FIFO date faster than the standard. Could you give me some clues about this issue? Thanks.

    6 REPLIES 6

    Community Moderator
    Community Moderator

    Please share your part of source code for sensor initialize and also the FIFO read out part with also the logic analyzer plotter on bus for 100K and 400KHz. 

    Thanks for the reply. Here is my code snippet:

    the init code logic about BMA425

    void bma425_init(void)
                  struct bma4_accel_config accel_conf;
    		/* Modify the accel handle parameters */
    		accel.dev_addr = BMA4_I2C_ADDR_PRIMARY;
    		accel.interface = BMA4_I2C_INTERFACE;
    		accel.bus_read = i2c_read_register;
    		accel.bus_write = i2c_write_register;
    		accel.delay = delay_x_ms;
    		accel.read_write_len = 8;
    	        /* Assign the desired settings for fifo */ = fifo_buff;
    		fifo_frame.length = BMA_MAX_BRUST_RD;
    		accel.fifo = &fifo_frame;
    	       /* Set up BMA425 device address */
    		/* Initialize the instance */
    		rslt |= bma423_init(&accel);
    		/* Enable the accelerometer */
    		rslt |= bma4_set_accel_enable(BMA4_MANUAL_ENABLE, &accel);
    		/* Assign the desired settings */
    		accel_conf.odr = BMA4_OUTPUT_DATA_RATE_6_25HZ;                
    		accel_conf.range = BMA4_ACCEL_RANGE_2G;
    		accel_conf.bandwidth = BMA4_ACCEL_OSR4_AVG1;
    		accel_conf.perf_mode = BMA4_CIC_AVG_MODE;
    		/* Set the configuration */
    		rslt |= bma4_set_accel_config(&accel_conf, &accel);
    		/* Disable the advanced power save mode to configure the FIFO buffer */
    		rslt |= bma4_set_advance_power_save(BMA4_ENABLE, &accel);
    		/* Configure the FIFO buffer */	
    		rslt |= bma4_set_fifo_config((BMA4_FIFO_ACCEL|BMA4_FIFO_HEADER), BMA4_ENABLE, &accel);
    		if (rslt != BMA4_OK) {
    		    MY_DBG("BMA425 init failed.\n\r");
    		} else {
    		    MY_DBG("BMA425 init OK.\n\r");

    In timer handler service we issue the FIFO read out:

    #define FRAME_SIZE (7)  /*< in header mode: 1B header + 6B accel */
    void handle_bma425_accel_fifo(void)
    	  uint16_t n_instances;
    	  int16_t n_expected;
    	  uint16_t fifo_len;
    	  bma4_set_advance_power_save(BMA4_DISABLE, &accel);
    	  bma4_get_fifo_length(&fifo_len, &accel);
    	  MY_DBG("FIFO len %d.\n\r", fifo_len);
    	  if (fifo_len < FIFO_WATERMARK_DEPTH) {
    			  MY_DBG("Read FIFO too fast [%d].\n\r", fifo_len);
              /* Consume 10 seconds accel data in Fifo */
    	  n_expected =62;
    	  do {
    			  n_instances = n_expected;
    				/* Read data from the sensor FIFO buffer */
    				bma4_extract_accel(&sens_data[62 - n_expected], &n_instances, &accel); 		  
    				n_expected -= n_instances;
    	  } while (n_expected > 0);
    	  if(n_expected==0) {			
    		  bma4_set_advance_power_save(BMA4_ENABLE, &accel); 
    		  // handle ACC data	


    when set as 400K, I2C bus timing is here:


    in standard mode, we see 10s fifo data handle is ~ 50ms


    but we set as fast mode, 120ms is observed.




    Community Moderator
    Community Moderator

    Let's shink down the problem first to see if the time difference is coming from bus read or somewhere else. 

    First we focus on following funciton execute time: 



    Before you call this, please adding the following setence:

    dev->fifo->length =  fifo_lengh;

    this fifo_length is get from previous API "bma4_get_fifo_length".  please also print this fifo_length out for debug. 


    Thanks for your reply !

    The following picture is the log of fifo length in the case of abnormal power consumption.

    We can be sure that the power consumption is getting longer not because of more data, but because of the problem of reading fifo(It shows a trend of decreasing length).

    Is there a problem with my other configuration?

    We are also doing some other related tests to look for problems and continue to wait for your Suggestions.



    Oscilloscope waveform.pngfifo_length.png