SPI Timout waiting for transfer complete

Hi there,

I'm having an issue with the SPI master in Zephyr. When attempting to transmit data it returns the error: 'Timeout waiting for transfer to complete'. Am I missing something here?

main.c:

#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/spi.h>

#define PN76_SPI DT_NODELABEL(pn76_spi)
#define PN76_SPI_OP (SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE)

LOG_MODULE_REGISTER(app);

void main(void) {
  struct spi_dt_spec pn76_spi = SPI_DT_SPEC_GET(PN76_SPI, PN76_SPI_OP, 0);

    bool ready = spi_is_ready(&pn76_spi);
    LOG_INF("Ready: %i", ready);

    unsigned char buffer[20] = { 0 };
    unsigned int length = sizeof(buffer);

    const struct spi_buf tx_buffer = {
        .buf = buffer,
        .len = length
    };

    const struct spi_buf_set tx_buffers = {
        .buffers = &tx_buffer,
        .count = 1
    };

    int status = spi_write_dt(&pn76_spi, &tx_buffers);
    LOG_INF("Status: %i", status);

	k_sleep(K_FOREVER);
}

DTS overlay:

/ {
    zephyr,user {
        pn76-enable-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
        pn76-dwl-req-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
        pn76-irq-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
    };
};

&pinctrl {
    spi1_default: spi1_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 6)>,
                    <NRF_PSEL(SPIM_MISO, 0, 7)>;
        };
    };

    spi1_sleep: spi1_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 6)>,
                    <NRF_PSEL(SPIM_MISO, 0, 7)>;
            low-power-enable;
        };
    };
};

&spi1 {
	compatible = "nordic,nrf-spim";
    status = "okay";

	pinctrl-0 = <&spi1_default>;
	pinctrl-1 = <&spi1_sleep>;
    cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;

    pn76_spi: spi-dev-a@0 {
        compatible = "vnd,spi-device";
        reg = <0>;
        spi-max-frequency = <1600000>;
    };
};

prj.conf:

CONFIG_SPI=y
CONFIG_LOG=y

Logs:

*** Booting Zephyr OS build v3.2.99-ncs1 ***
[00:00:00.373,657] <inf> app: Ready: 1
[00:00:00.573,791] <err> spi_nrfx_spim: Timeout waiting for transfer complete
[00:00:00.573,822] <inf> app: Transmit status: -116

nRF Connect version: v2.2.0

Zephyr version: 3.2.99

Best regards,

Stefan Nienhuis

Parents Reply Children
Related