Bosch Sensortec Community

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

    Unable to connect BMI270 Shuttle board using SPI

    Unable to connect BMI270 Shuttle board using SPI

    Yafra7
    New Poster

    Hi,

    We're trying to use the BMI270 shuttle board using SPI with the Nordic chip nrf52840 but the connection init keeps failing.

     

    We followed the shuttle board datasheet (https://www.bosch-sensortec.com/media/boschsensortec/downloads/shuttle_board_flyer/bst-dhw-fl040.pdf) and connected  as following :

    VDD and VDDIO to 2.8V

    SDO -> Pin 30 on the Nordic DK

    SDI -> Pin 29 on the Nordic DK

    SCK -> Pin 26 on the Nordic DK

    CSB_BMI270 -> Pin 31 on the Nordic DK

     

    We also removed all the connectors on the top of the shuttle board (since we're not sure exactly what they do).

     

    The code we used is the following , it's made with nordic sdk + the bmi270 api (https://github.com/BoschSensortec/BMI270-Sensor-API)

    #define CS_PIN 31
    #define SCK_PIN 26
    #define MOSI_PIN 29
    #define MISO_PIN 30
    
    static const nrf_drv_spi_t spi_instance = NRF_DRV_SPI_INSTANCE(0);
    
    static struct bmi2_dev bmi270_dev;
    
    static void init_bmi270()
    {
        int8_t res = BMI2_OK;
    
        bmi270_dev.chip_id = BMI270_CHIP_ID;
        bmi270_dev.dummy_byte = 1;
        bmi270_dev.read_write_len = 32; // also tried read_write_len= 8192  as in github arduino gist
        bmi270_dev.intf = BMI2_SPI_INTF;
        bmi270_dev.read = hdc_user_spi_read;
        bmi270_dev.write = hdc_user_spi_write;
        bmi270_dev.delay_us = hdc_user_delay_us;
        bmi270_dev.config_file_ptr = NULL;
    
    
         res = bmi270_init(&bmi270_dev);
         switch (res) {
             case BMI2_OK:
                 NRF_LOG_INFO("Init Bmi270 OK :)");
                 break;
            case BMI2_E_COM_FAIL:
                 NRF_LOG_INFO("Init Bmi270 BMI2_E_COM_FAIL");
                 break;
            case BMI2_E_NULL_PTR:
                 NRF_LOG_INFO("Init Bmi270 BMI2_E_NULL_PTR");
                 break;
            case BMI2_E_DEV_NOT_FOUND:
                NRF_LOG_INFO("Init Bmi270 BMI2_E_DEV_NOT_FOUND");
                 break;
         }
         NRF_LOG_INFO("Bmi270 init : %d", res);
    }
    
    void imu_init(void)
    {
        // init spi
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin     = CS_PIN_IMU;
        spi_config.miso_pin   = SPI0_CONFIG_MISO_PIN;
        spi_config.sck_pin    = SPI0_CONFIG_SCK_PIN;
        spi_config.mosi_pin = SPI0_CONFIG_MOSI_PIN;
        spi_config.frequency  = NRF_DRV_SPI_FREQ_2M;
        spi_config.mode       = NRF_DRV_SPI_MODE_0;
        spi_config.bit_order  = (nrf_drv_spi_bit_order_t) NRF_SPI_BIT_ORDER_MSB_FIRST;
        uint32_t err_code = nrf_drv_spi_init(&spi_instance, &spi_config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
    
        nrf_gpio_cfg_output(CS_PIN_IMU);
        nrf_gpio_pin_set(CS_PIN_IMU);
    
        init_bmi270();
    }

     

     And the we always fall in the 'case BMI2_E_NULL_PTR' after calling bmi270_init.

    Thanks for your time,

    Yohann

    5 REPLIES 5

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Yafra7,

    The functions definitions were correct from your code.

    Suggest you set a break point to bmi270_init( ), and do single step debug to see which code return BMI2_E_NULL_PTR.

    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