simply spi master in nr54l15 to read from lis2dw12

Hi Nordic Semi,

Instead of using NRF52 for previous projects, I am new in NRF54L15 and zephyr.

I have started the blinky pwm sample in VSC and tried a lot to just read from SPI withou any luck.

I have connected a LIS2DW12 to spi0 and set it in dts file .  but the program crashes as soon as i try to read register from the chip or even calling

spi_transceive. with bellow output on the terminal.
*** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
*** Using Zephyr OS v4.0.99-f791c49f492c ***
[00:00:00.012,062] <err> os: ***** Reserved Exception ( -16) *****
[00:00:00.018,864] <err> os: r0/a1: 0x20001a20 r1/a2: 0x00002ce9 r2/a3: 0x0000909b
[00:00:00.027,549] <err> os: r3/a4: 0x00002cd5 r12/ip: 0x00002cd5 r14/lr: 0x00002cd5
[00:00:00.036,229] <err> os: xpsr: 0x00002c00
[00:00:00.041,447] <err> os: Faulting instruction address (r15/pc): 0x00002cd5
[00:00:00.049,356] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.057,172] <err> os: Current thread: 0x20000358 (main)
[00:00:00.063,682] <err> os: Halting system
i attached the related program , conf and dts files. 
Thanks a lot for your help.
76202.prj.conf
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>

#define SPI_DEV_NODE    DT_NODELABEL(spi00)

static struct spi_cs_control cs_ctrl = {
    .gpio = SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(spi00)),
    .delay = 0,
};

void main(void)
{
    const struct device *spi_dev = DEVICE_DT_GET(SPI_DEV_NODE);

    if (!device_is_ready(spi_dev)) {
        printk("SPI device not ready\n");
        return;
    }

    struct spi_config spi_cfg = {
        .frequency = 4000000,
        .operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_OP_MODE_MASTER  ,
        .cs = &cs_ctrl,
    };

    // Prepare buffers: [register | 0x80 for read], [0x00 dummy]
    uint8_t tx_buf[2] = { 0x0F | 0x80, 0x00 }; // 0x0F WHO_AM_I
    uint8_t rx_buf[2] = { 0, 0 };

    struct spi_buf tx = { .buf = tx_buf, .len = 2 };
    struct spi_buf rx = { .buf = rx_buf, .len = 2 };
    struct spi_buf_set tx_set = { .buffers = &tx, .count = 1 };
    struct spi_buf_set rx_set = { .buffers = &rx, .count = 1 };

printk("Before spi_transceive\n");
int ret = spi_transceive(spi_dev, &spi_cfg, &tx_set, &rx_set);
printk("After spi_transceive: %d\n", ret);
    if (ret == 0) {
        printk("SPI WHO_AM_I read: 0x%02x\n", rx_buf[1]); // Data is in rx_buf[1]
    } else {
        printk("SPI read failed: %d\n", ret);
    }

    while (1) {
        k_sleep(K_MSEC(1000));
    }


}
0167.nrf54l15dk_nrf54l15_cpuapp.dts
Related