Bosch Sensortec Community

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

    BMI I2C: Shuttle board connections and write/read functions

    BMI I2C: Shuttle board connections and write/read functions

    SaberKazemi1992
    Established Member

    Hi Bosch sesnrtec community

    I am using BMI160 IMU (shuttle board) as motion sesnor in my application. The MCU is MSP432P401R.

    1- What is the proper wiring configuration for the shuttle board for I2C protocol?

    2- I have written the code for I2C read/write functions like below:

    /************BMI160 I2C*********/
    UCB1CTLW0 |= UCSWRST; // **Initialize USCI state machine**
    P6SEL0 |= BIT4 + BIT5;
    P6SEL1 &= ~(BIT4 + BIT5); // | P6.3: UCB1SCLK| P6.4: UCB1SIMO | P6.5: UCB1SOMI (Refer to the datasheet, page: 159).
    UCB1CTLW0 |= UCCKPH + UCMST + UCMSB + UCSYNC + UCSSEL_2 + UCMODE_3; // 3-pin, 8-bit, SPI master
    UCB1BR0 = 12; // fSCL = SMCLK/12 = ~250kHz
    UCB1BR1 = 0;
    UCB1I2CSA = BMI160_I2C_ADDR; // Set slave address
    UCB1CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**

    int8_t user_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
    {
    int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */

    /*
    * The parameter dev_id can be used as a variable to store the I2C address of the device
    */
    UCB1CTLW0 |= UCTR + UCTXSTT; // I2C TX, start condition
    UCB1TXBUF = reg_addr; // Write reg_addr byte
    UCB1CTLW0 |= UCTXSTP; // I2C stop condition.

    UCB1I2CSA |= BMI160_I2C_ADDR; // Set slave address
    UCB1CTLW0 &=~UCA10; //10BIT ADDRESS
    UCB1CTLW0 &=~UCTR;//CLEAR TRANSMIT MODE
    UCB1CTLW0 |= UCTXSTT; // I2C RX, start condition
    int i=0;
    for (i=0;i<len;i++)
    {
    reg_data[i]=UCB1RXBUF;
    }
    UCB1CTLW0 |= UCTXSTP; // I2C stop condition.

    return rslt;
    }

    int8_t user_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
    {
    int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */
    UCB1CTLW0 |= UCTR + UCTXSTT; // I2C TX, start condition
    UCB1TXBUF = reg_addr; // Write reg_addr byte
    int i=0;
    for (i=0;i<len;i++)
    {
    UCB1TXBUF=reg_data[i];
    }
    UCB1CTLW0 |= UCTXSTP; // I2C stop condition.

    return rslt;
    }

     Is it the right statement for them?

    Thanks

    Saber

    6 REPLIES 6

    Thanks for your previous answers.

    I have one more question with regard the pin connections. In the datasheet, page 100, it is mentioned that that GND should be connected to the VDDIO with 100 nF capacitor. As I am using the shuttle board, do I need to connect these two pins externally or they are already connected in the board?

     

    bmi160 i2c pin connection.png

    Thanks

    Saber 

    no, the shuttle has its own decoupling.
    o_o
    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