This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

No Data on SPIM MISO line nrf9160

Hi all,

I am interfacing with an MCP25625 device using SPIM3 on the nRF9160 and I am receiving no response on the MISO line. I have verified the correct functionality of the MCP25625 device using the MSP432 microcontroller, so I know that it is working correctly.

I have been using a logic analyzer to sniff the SPI3 bus, and I can see data being sent on the MOSI line. I have verified all the writes for initializing the MCP25625, as well as reading from the RX buffers. I have tried changing MISO pins, changing SPI speed, re-written my transceieve function, but still nothing. I am wondering if I have missed something in the dts file, prj.conf file, or something. I still new to zephyr and getting used to it. I will paste my code and config files below.

//spi transceieve function
void nrf_spi_transceive(uint8_t *data_tx, uint8_t *data_rx, uint8_t rxBytes, uint8_t txBytes)
{
    cs_pin.gpio_dev = gpio_device;
    int err;
    //setup buffers
    //SPI buffer struct for transmitting
    struct spi_buf tx_buf[] = {
        {
            .buf = data_tx,
            .len = txBytes,
        }
    };
    //SPI buffer struct for receving
    struct spi_buf rx_buf[] = {
        {
        .buf = data_rx,
        .len = rxBytes,
        }
    };

    //SPI buffer array structure for transmit buffer
    struct spi_buf_set set_tx = {
        .buffers = &tx_buf,
        .count = ARRAY_SIZE(tx_buf),
    };
    //SPI buffer array structure for receive buffer
    struct spi_buf_set set_rx = {
        .buffers = &rx_buf,
        .count = ARRAY_SIZE(rx_buf)
    };

    err = spi_transceive(spi_dev, &spi_cfg, &set_tx, &set_rx);

    if (err)
    {
        printk("SPI failed to send: %d\n", err);
    }
    else
    {
        printk("Data sent without error\n");
    }
}
//where spi transceive is called
void mcp25625_read_rx_buffer(uint8_t destination, uint8_t* data_out)
{
    uint8_t offset;
    uint8_t data_in[13];
    int index;

    if(destination == 0)
    {
        offset = 0x0; //RXB0
    }
    else
    {
        offset = 0x4; //RXB1
    }

    //CMD_READ_RX_BUFFER
    data_in[0] = CMD_READ_RX_BUFFER + offset;
    for (index = 1; index < 13; index++)
    {
        data_in[index] = 0;
    }
    
    nrf_spi_transceive(data_in, data_out, 13, 13);

}

//dts file
&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <10>;
	ss-pin = <13>;
	mosi-pin = <11>;
	miso-pin = <12>;
};

//prj.conf file
CONFIG_SERIAL=y

CONFIG_SPI=y
CONFIG_SPI_3=y
CONFIG_SPI_NRFX=y
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_GPIO=y

Thank for you for your help and assistance!

Sincerely,

Kyle Garland

Related