nRF54l15 SPI slave not work as expected

I am trying to setup SPI00 as SPI slave on nrf54l15 but not work as expected.

My board configure is like 

&pinctrl {
    spi00_default: spi00_default {
        group1 {
            psels = <NRF_PSEL(SPIS_SCK, 2, 1)>,  /* SCK Input */
                    <NRF_PSEL(SPIS_MOSI, 2, 2)>, /* MOSI Input */
                    <NRF_PSEL(SPIS_MISO, 2, 4)>, /* MISO Output */
                    <NRF_PSEL(SPIS_CSN, 2, 5)>;  /* CS Input - Must be here! */
        };
    };
    spi00_sleep: spi00_sleep {
        group1 {
            psels = <NRF_PSEL(SPIS_SCK, 2, 1)>,  /* SCK Input */
                    <NRF_PSEL(SPIS_MOSI, 2, 2)>, /* MOSI Input */
                    <NRF_PSEL(SPIS_MISO, 2, 4)>, /* MISO Output */
                    <NRF_PSEL(SPIS_CSN, 2, 5)>;  /* CS Input - Must be here! */
        };
    };
};


&spi00 {
    status = "okay";
    compatible = "nordic,nrf-spis";
    pinctrl-0 = <&spi00_default>;
    pinctrl-1 = <&spi00_sleep>;
    pinctrl-names = "default","sleep";
    def-char = <0x00>;
    /delete-property/ rx-delay-supported;
    /delete-property/ rx-delay;
};

and c program like

#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/kernel.h>
#include <zephyr/types.h>
#include <zephyr/drivers/spi.h>

#define SPI_NODE DT_NODELABEL(spi00)
static const struct device *spi_dev = DEVICE_DT_GET(SPI_NODE);

struct spi_config spis_cfg = {
          .frequency = 0, /* Frequency is controlled entirely by the Master */
        .operation = SPI_WORD_SET(8) | SPI_OP_MODE_SLAVE,
};



int main(void)
{
	int err;
	int ret_val;
	uint8_t rx_buffer[32] = {
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89
	                        };
	uint8_t tx_buffer[32] = {
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89
	                        };


    if (!device_is_ready(spi_dev)) {
		printk("UART device not found!");
		return 0;
	}

	while (true) {
			printk("waiting for request\r\n");
		
    struct spi_buf tx_buf = { .buf = tx_buffer, .len = sizeof(tx_buffer) };
    struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };

    struct spi_buf rx_buf = { .buf = rx_buffer, .len = sizeof(rx_buffer) };
    struct spi_buf_set rx_bufs = { .buffers = &rx_buf, .count = 1 };
  		spi_transceive(spi_dev, &spis_cfg, &tx_bufs, &rx_bufs);

  		printk("spi work done\n");
				
	}
	/* return to idle thread */
	return 0;
}
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/kernel.h>
#include <zephyr/types.h>
#include <zephyr/drivers/spi.h>

#define SPI_NODE DT_NODELABEL(spi00)
static const struct device *spi_dev = DEVICE_DT_GET(SPI_NODE);

struct spi_config spis_cfg = {
          .frequency = 0, /* Frequency is controlled entirely by the Master */
        .operation = SPI_WORD_SET(8) | SPI_OP_MODE_SLAVE,
};



int main(void)
{
	int err;
	int ret_val;
	uint8_t rx_buffer[32] = {
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89
	                        };
	uint8_t tx_buffer[32] = {
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89,
	                  0xab,0xcd,0xef,0xee,0xaa,0xff,0x12,0x89
	                        };


    if (!device_is_ready(spi_dev)) {
		printk("UART device not found!");
		return 0;
	}

	while (true) {
			printk("waiting for request\r\n");
		
    struct spi_buf tx_buf = { .buf = tx_buffer, .len = sizeof(tx_buffer) };
    struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };

    struct spi_buf rx_buf = { .buf = rx_buffer, .len = sizeof(rx_buffer) };
    struct spi_buf_set rx_bufs = { .buffers = &rx_buf, .count = 1 };
  		spi_transceive(spi_dev, &spis_cfg, &tx_bufs, &rx_bufs);

  		printk("spi work done\n");
				
	}
	/* return to idle thread */
	return 0;
}

The program intends to use nrf54L15 builtin supported SPI module as slave. Each time it receive SPI master's polling request. it should send back data to master in rx_buffer. 

I connect nRF54l15 with nrf52833 and nrf52833 works as SPI master. But nRF54l15 will hangs at "spi_transceive" forever whenever master send 32 bytes through SPI bus.

I have browse some of discussion about spi slave before. And I don't know how to address this issue. I prefer not to change pin assignment to address this because I already have manufactured small amount of hardware samples.

Parents
  • Hi,

    I'm sorry, but I believe that your issue here is indeed because of your pin mapping... If we follow closely the documentation (link), I think that you mixed up the MISO and MOSI pins.

    P2.01 SPIS SCK OK
    P2.02 SPIS SDO NOT OK (MOSI = slave SDI)
    P2.04 SPIS SDI NOT OK (MISO = slave SDO)
    P2.05 SPIS CSN OK

    Do you have any way of trying to cross these traces/wires on your board? 

    Best regards,

    Simon

  • Hi, Simon

    I have remaped pin in board files and swap MISO/MOSI wiring. But still got spi_transceive hangs.

    I also posted the prj.conf, which may help this.

    CONFIG_SPI=y
    CONFIG_SPI_SLAVE=y
    CONFIG_SPI_ASYNC=y
    
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_LOG=y

    nrf52833 just runs a spim example running 8M spi sck and I verify it by logic analyzer.

    I can also post my nrf52833 SPIM project if it can help.

    By the way, don't worry about it. We are also considering another solution if nrf54L15 SPIS cannot be fit in.

Reply
  • Hi, Simon

    I have remaped pin in board files and swap MISO/MOSI wiring. But still got spi_transceive hangs.

    I also posted the prj.conf, which may help this.

    CONFIG_SPI=y
    CONFIG_SPI_SLAVE=y
    CONFIG_SPI_ASYNC=y
    
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_LOG=y

    nrf52833 just runs a spim example running 8M spi sck and I verify it by logic analyzer.

    I can also post my nrf52833 SPIM project if it can help.

    By the way, don't worry about it. We are also considering another solution if nrf54L15 SPIS cannot be fit in.

Children
No Data
Related