08-26-2020 10:58 AM
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
Solved! Go to Solution.
08-31-2020 04:00 AM
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.