[NRF5340] SPI RX Buffer always empty

I'm trying to establish a connection with an ICM-20948 via SPI. I check the pins and they are correct but the RX buffer always returns 0x00 when I call to "whoami".


The GPIO and SPI config:

nrfx_spim_config_t spim_config = {
      .sck_pin      = APP_SPIM_SCK_PIN,
      .mosi_pin     = APP_SPIM_MOSI_PIN,
      .miso_pin     = APP_SPIM_MISO_PIN,
      .ss_pin       = APP_SPIM_CS_PIN,
      .ss_active_high = false,
      .irq_priority = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY,
      .orc          = 0xFF,
      .frequency    = NRF_SPIM_FREQ_4M,
      .mode         = NRF_SPIM_MODE_0,
      .bit_order    = NRF_SPIM_BIT_ORDER_MSB_FIRST,
      .miso_pull    = NRF_GPIO_PIN_NOPULL,    
      .dcx_pin      = NRFX_SPIM_PIN_NOT_USED,
      .rx_delay     = 0x02,
      .use_hw_ss    = false,
      .ss_duration  = 0x02,
  };

nrfx_spim_init(&spim, &spim_config, spim_event_handler, NULL);
gpio_pin_configure(GPIO0_PORT, APP_SPIM_CS_PIN, GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW); 


The comm code:

  gpio_pin_set(GPIO0_PORT, APP_SPIM_CS_PIN, true);
  
  m_tx_buf[0] = ((REG_WHO_AM_I & 0x7F) | 0x80);
  nrfx_spim_xfer(&spim, &xfer_desc, 0);
  waitData = true;
  while(waitData) {
    __WFE();
  }  
  for(int32_t i = 0; i < len; i++)
  {
    printk("%i ",  xfer_desc.p_rx_buffer[i]);
  }
  gpio_pin_set(GPIO0_PORT, APP_SPIM_CS_PIN, false);

My SPI0 devicetree:

spi0: spi@8000 {
        compatible = "nordic,nrf-spim";
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0x8000 0x1000>;
        interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
        max-frequency = <DT_FREQ_M(8)>;
        status = "okay";
        cs-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi0_default>;
        pinctrl-names = "default";
};

spi0_default: spi0_default {
    group1 {
        psels = <NRF_PSEL(SPIM_SCK, 0, 18)>,
                <NRF_PSEL(SPIM_MISO, 0, 26)>,
                <NRF_PSEL(SPIM_MOSI, 0, 17)>;
    };
};

Did I forget something to config?

Parents Reply Children
Related