nRF54L15 spi slave

Hi :
 Here is the initialization in C: 


#define SPIS_INST_IDX       22
static nrfx_spis_t spis_inst = NRFX_SPIS_INSTANCE(SPIS_INST_IDX);
void device_spis_init(void)
{
    nrfx_err_t status;
    (void)status;

#if defined(__ZEPHYR__)
    IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIS_INST_GET(SPIS_INST_IDX)), IRQ_PRIO_LOWEST, \
                NRFX_SPIS_INST_HANDLER_GET(SPIS_INST_IDX), 0, 0);
#endif

    nrfx_spis_config_t spis_config = NRFX_SPIS_DEFAULT_CONFIG(6,
                                                              9,
                                                              8,
                                                              10);

    spis_config.mode = NRF_SPIS_MODE_3;
    spis_config.def = 0xFF;

    memset(m_tx_buffer_slave, 0x55, sizeof(m_tx_buffer_slave));
    memset(m_rx_buffer_slave, 0xaa, sizeof(m_rx_buffer_slave));

    status = nrfx_spis_init(&spis_inst, &spis_config, spis_handler, NULL);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    status = nrfx_spis_buffers_set(&spis_inst,
                                   m_tx_buffer_slave, 36,
                                   m_rx_buffer_slave, 36);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    printk("%s %d\n", __func__, status);

    printk("%s success\n", __func__);
}
&spi22 {
    status = "okay";
    easydma-maxcnt-bits = <8>;
    compatible = "nordic,nrf-spis";
    max-frequency = <DT_FREQ_M(32)>;
    def-char = <0x00>;
    /delete-property/ rx-delay-supported;
    /delete-property/ rx-delay;
    cs-gpios = <&gpio2 10 0>;
    pinctrl-0 = <&spi22_default>;
    pinctrl-names = "default";
    zephyr,deferred-init;
};
here is the prj file:
CONFIG_SPI_SLAVE=y
CONFIG_NRFX_SPIS22=y
I completed the above initialization, but I couldn't receive any data from the slave device. The callback function didn't execute. I can confirm that the wiring of the SPI master end and the I/O is correct.  Could you please tell me if there are any abnormalities with this initialization?
Parents
  • HI!

        nrfx_spis_config_t spis_config = NRFX_SPIS_DEFAULT_CONFIG(6,
                                                                  9,
                                                                  8,
                                                                  10);

    Try using pins from port 1 instead.

    https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/overview.html

    NRF_GPIO_PIN_MAP(1,4) // port 1 , pin 4

    For  SCK signal, this need to be a Clock pin. https://docs.nordicsemi.com/bundle/ps_nrf54L15/page/chapters/pin.html#ariaid-title3 , so e.g. this could be P1.04

  • This pin has been used for uart. And I use the P1.03 for SCK. There is still no way to communicate. 

        spi22_default: spi22_default {
            group1 {
                psels = <NRF_PSEL(SPIS_SCK, 1, 3)>,
                        <NRF_PSEL(SPIS_MOSI, 1, 2)>,
                        <NRF_PSEL(SPIS_MISO, 1, 1)>;
            };
    &spi22 {
        status = "okay";
        compatible = "nordic,nrf-spis";
        max-frequency = <DT_FREQ_M(16)>;
        easydma-maxcnt-bits = <8>;
        def-char = <0xFF>;
        /delete-property/ rx-delay-supported;
        /delete-property/ rx-delay;
        cs-gpios = <&gpio1 0 0>;
        pinctrl-0 = <&spi22_default>;
        pinctrl-names = "default";
        zephyr,deferred-init;
    };

    CONFIG_DYNAMIC_INTERRUPTS=y

    CONFIG_NRFX_GPPI=y
    CONFIG_CLOCK_CONTROL=y

    CONFIG_MINIMAL_LIBC=y
    # CONFIG_SPI=y
    CONFIG_SENSOR=y
    CONFIG_SPI_SLAVE=y
    CONFIG_LED=y
    CONFIG_PM_CPU_OPS=y
    CONFIG_NRFX_SPIS22=y
     
    #define SPIS_INST_IDX       22
     
    void device_spis_init(void)
    {
        nrfx_err_t status;
        (void)status;

       IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_SPIS_INST_GET(SPIS_INST_IDX)), IRQ_PRIO_LOWEST,
                    NRFX_SPIS_INST_HANDLER_GET(SPIS_INST_IDX), 0, 0);

        nrfx_spis_config_t spis_config = NRFX_SPIS_DEFAULT_CONFIG(3,
                                                                  2,
                                                                  1,
                                                                  0);

        spis_config.mode = NRF_SPIS_MODE_3;

        status = nrfx_spis_init(&spis_inst, &spis_config, spis_handler, &spis_inst);
        NRFX_ASSERT(status == NRFX_SUCCESS);

        status = nrfx_spis_buffers_set(&spis_inst,
                                       m_tx_buffer_slave, sizeof(m_tx_buffer_slave),
                                       m_rx_buffer_slave, sizeof(m_rx_buffer_slave));
        NRFX_ASSERT(status == NRFX_SUCCESS);

        printk("%s %d\n", __func__, status);
    }
  • May I ask if I need to enable the SPI clock? If so, how should I do it?

  • No, you are the SPIS(slave) here, it's the other device, the SPIM(master) that generates the clock.

    Do you have any log output (e.g. from UART backend) that could tell us more about the issue?

  • yes, uart can output log. This is main func. 

    here is spis callback func:

    static void spis_handler(nrfx_spis_evt_t const * p_event, void * p_context)
    {
        if (p_event->evt_type == NRFX_SPIS_XFER_DONE)
        {
            nrfx_err_t status;
            (void)status;

            nrfx_spis_t * p_spis_inst = p_context;

            printk("SPIS finished.");

            if (p_event->tx_amount > 0)
            {
                printk("SPIS: Message transmitted: %d", p_event->tx_amount);
            }

            if (p_event->rx_amount > 0)
            {
                printk("SPIS: Message received: %d", p_event->rx_amount);
            }

            status = nrfx_spis_buffers_set(p_spis_inst, m_tx_buffer_slave, PACKET_MAX_SIZE, m_rx_buffer_slave, PACKET_MAX_SIZE);
            NRFX_ASSERT(status == NRFX_SUCCESS);
        }
    }
Reply
  • yes, uart can output log. This is main func. 

    here is spis callback func:

    static void spis_handler(nrfx_spis_evt_t const * p_event, void * p_context)
    {
        if (p_event->evt_type == NRFX_SPIS_XFER_DONE)
        {
            nrfx_err_t status;
            (void)status;

            nrfx_spis_t * p_spis_inst = p_context;

            printk("SPIS finished.");

            if (p_event->tx_amount > 0)
            {
                printk("SPIS: Message transmitted: %d", p_event->tx_amount);
            }

            if (p_event->rx_amount > 0)
            {
                printk("SPIS: Message received: %d", p_event->rx_amount);
            }

            status = nrfx_spis_buffers_set(p_spis_inst, m_tx_buffer_slave, PACKET_MAX_SIZE, m_rx_buffer_slave, PACKET_MAX_SIZE);
            NRFX_ASSERT(status == NRFX_SUCCESS);
        }
    }
Children
No Data
Related