nrf_drv_spi_transfer always returns all 0's from device.

I'm using SDK 14.2.0.

I'm trying to read the device ID register from ISM330DHCX accelerometer this way:

ret = nrf_drv_spi_transfer(&m_spi[Instance], &reg_addr, 1, read_temp, length + 1);

In the function nrf_drv_spi_transfer() NRF_DRV_SPI_USE_SPIM and SPIM_PRESENT are both true and nrfx_spim_xfer() is called.

I can't figure out if nrfx_spim_xfer() is using the parameters passed by nrf_drv_spi_transfer() above. Is it using reg_addr? Is it using the correct chip select?

My spi config:

const nrf_drv_spi_config_t spi_ism330_config =
{ \
.sck_pin = NRF_GPIO_PIN_MAP(0, 8), \
.mosi_pin = NRF_GPIO_PIN_MAP(0, 6), \
.miso_pin = NRF_GPIO_PIN_MAP(0, 5), \
.ss_pin = NRF_GPIO_PIN_MAP(0, 7), \
.irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
.orc = 0xFF, \
.frequency = NRF_DRV_SPI_FREQ_125K, \
.mode = NRF_DRV_SPI_MODE_3, \
.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
};

I have tried to read the device ID register of a different device using this same procedure and it also returns 0x00, 0x00. I have a feeling there is some sdk config issue.

1258.sdk_config.h

Parents
  • Thanks for the quick response.

    I am using an nRF52840-DK development board.

    I will look into the uart config but since I'm using a development board I can find some other pins to use.

    I have three spi devices using gpio pins as listed below. Do you see any other conflicts?

    const nrf_drv_spi_config_t spi_ism330_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 8), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 6), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 5), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 7), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_125K, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    // Magnetometer
    const nrf_drv_spi_config_t spi_lis3_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 25), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 23), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 22), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 24), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_125K, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    // Accelerometer
    const nrf_drv_spi_config_t spi_adxl372_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 17), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 14), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 15), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 16), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_4M, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    Regards.

    David

Reply
  • Thanks for the quick response.

    I am using an nRF52840-DK development board.

    I will look into the uart config but since I'm using a development board I can find some other pins to use.

    I have three spi devices using gpio pins as listed below. Do you see any other conflicts?

    const nrf_drv_spi_config_t spi_ism330_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 8), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 6), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 5), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 7), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_125K, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    // Magnetometer
    const nrf_drv_spi_config_t spi_lis3_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 25), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 23), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 22), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 24), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_125K, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    // Accelerometer
    const nrf_drv_spi_config_t spi_adxl372_config =
    { \
    .sck_pin = NRF_GPIO_PIN_MAP(0, 17), \
    .mosi_pin = NRF_GPIO_PIN_MAP(0, 14), \
    .miso_pin = NRF_GPIO_PIN_MAP(0, 15), \
    .ss_pin = NRF_GPIO_PIN_MAP(0, 16), \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc = 0xFF, \
    .frequency = NRF_DRV_SPI_FREQ_4M, \
    .mode = NRF_DRV_SPI_MODE_3, \
    .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST \
    };

    Regards.

    David

Children
No Data
Related