Hello team,
I am trying to interface the AT45DB641E flash with the nrf54l15 on a custom board. I am using the SPI00 instance.
Below is the configuration I set in .overlay file
&pinctrl {
spi00_default: spi00_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
<NRF_PSEL(SPIM_MOSI, 2, 2)>,
<NRF_PSEL(SPIM_MISO, 2, 4)>;
nordic,drive-mode = <NRF_DRIVE_E0E1>;
};
};
spi00_sleep: spi00_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 2, 1)>,
<NRF_PSEL(SPIM_MOSI, 2, 2)>,
<NRF_PSEL(SPIM_MISO, 2, 4)>;
nordic,drive-mode = <NRF_DRIVE_E0E1>;
low-power-enable;
};
};
};
&spi00 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi00_default>;
pinctrl-1 = <&spi00_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
at45db641e: at45db641e@0 {
compatible = "atmel,at45";//"zephyr,spi-device";
reg = <0>;
spi-max-frequency = <8000000>;
label = "AT45DB641E";
status = "okay";
jedec-id = [1f 28 00]; /* optional but helpful */
size = <0x800000>; /* 4 MByte = 32 Mbit */
sector-size = <262144>;
block-size = <2048>;
page-size = <256>;
};
};
And below is the code I am using to read the ID of the flash
void data_write_spi()
{
if (!device_is_ready(spi_dev)) {
printf("SPI device not ready");
return;
}
uint8_t cmd[4];
uint8_t rx[5];
cmd[0] = 0x9F;
struct spi_buf tx_bufs = {.buf = cmd, .len = 1};
struct spi_buf rx_bufs = {.buf = rx, .len = 5};
struct spi_buf_set tx = {.buffers = &tx_bufs, .count = 1};
struct spi_buf_set rx_set = {.buffers = &rx_bufs, .count = 1};
k_msleep(5);
int ret = spi_transceive(spi_dev, &spi_cfg, &tx, &rx_set);
if (ret == 0) {
printf("JEDEC ID: %02X %02X %02X %02x %02x", rx[0], rx[1], rx[2], rx[3], rx[4]);
} else {
printf("SPI transfer failed: %d", ret);
}
}
I am getting the following error.
SPI transfer failed: -5
How can I fix this issue so I can use spi00 appropriately? Any help would be greatly appreciated.
Thanks,
Payal