Winbond Flash W25Q32JV/W25Q16JV with nrf52833 DK .

HI , I am having difficulty in interfacing the flash with my DK board 

1) The spi flash sample is getting stuck at flash erase function without any error responses

2) I have used SPI interfacing with other devices and it is working .

3) Flash Board has been tested with other controllers 

4) I wrote a sample code to just read manufacture id from the flash but it is not giving any response , the code and logic analyzer capture is below

#include <zephyr.h>
#include <sys/printk.h>
#include <device.h>
#include <drivers/spi.h>
#include <hal/nrf_gpio.h>
#include <kernel.h>
#include <devicetree.h>


#define SPI_MODE_CPOL 0
#define SPI_MODE_CPHA 0

struct spi_cs_control spim_cs_one = { 
                            .gpio.dt_flags=GPIO_ACTIVE_LOW,
							.gpio.pin=20,
    						.delay = 0,
};

static const struct spi_config spi_cfg = {
	.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB |
		     SPI_MODE_CPOL | SPI_MODE_CPHA,
	.frequency = 1000000,
	.slave = 0,
	.cs= &spim_cs_one
};

struct device * spi_dev;

 void spi_init(void)
{
	spim_cs_one.gpio.port=  DEVICE_DT_GET(DT_NODELABEL(gpio0));
	spi_dev = device_get_binding("SPI_1");

	if (spi_dev == NULL) {
		printk("Could not get %s device\n", spi_dev);
		return;
	}
}

void spi_test_send(void)
{
	int err;
	static uint8_t tx_buffer[1];
	static uint8_t rx_buffer[1];

	const struct spi_buf tx_buf = {
		.buf = tx_buffer,
		.len = sizeof(tx_buffer)
	};
	const struct spi_buf_set tx = {
		.buffers = &tx_buf,
		.count = 1
	};

	struct spi_buf rx_buf = {
		.buf = rx_buffer,
		.len = sizeof(rx_buffer),
	};
	const struct spi_buf_set rx = {
		.buffers = &rx_buf,
		.count = 1
	};

	tx_buffer[0]=0x9F;
	 err = spi_transceive(spi_dev, &spi_cfg, &tx,&rx);
	tx_buffer[0]=0x00;
	 err = spi_transceive(spi_dev, &spi_cfg, &tx,&rx);
	tx_buffer[0]=0x00;
	 err = spi_transceive(spi_dev, &spi_cfg, &tx,&rx);
	tx_buffer[0]=0x00;
	 err = spi_transceive(spi_dev, &spi_cfg, &tx,&rx);
}

void main(void)
{
	printk("SPIM Example\n");
	spi_init();

	while (1) {
		spi_test_send();
		k_sleep(K_SECONDS(1));
	}
}
--------------------------------------------------------------------------------------------------------
also tried 

void spi_test_send(void)
{
	int err;
	static uint8_t tx_buffer[4]={
		0x9F,
		0x00,
		0x00,
		0x00
	};
	static uint8_t rx_buffer[4];

	const struct spi_buf tx_buf = {
		.buf = tx_buffer,
		.len = sizeof(tx_buffer)
	};
	const struct spi_buf_set tx = {
		.buffers = &tx_buf,
		.count = 1
	};

	struct spi_buf rx_buf = {
		.buf = rx_buffer,
		.len = sizeof(rx_buffer),
	};
	const struct spi_buf_set rx = {
		.buffers = &rx_buf,
		.count = 1
	};
	nrf_gpio_pin_set(20);
	nrf_gpio_pin_clear(20);
	k_busy_wait(80);
	nrf_gpio_pin_set(20);
	k_busy_wait(20);
	nrf_gpio_pin_clear(20);
	 err = spi_transceive(spi_dev, &spi_cfg, &tx,&rx);
	if (err) {
		printk("SPI error: %d\n", err);
	} 
	for(int i =4 ;i>0;i--){
	 printk("%x",rx_buffer[3]);
	}
}
----------------------------------------------------------------------------------------------------------

DT 
&spi1 {
	compatible = "nordic,nrf-spi";
	status = "okay";
	cs-gpios = <&arduino_header 20 GPIO_ACTIVE_LOW>; /* D10 */
	pinctrl-0 = <&spi3_default>;
	pinctrl-1 = <&spi3_sleep>;
	pinctrl-names = "default", "sleep";
	label = "SPI_3";
};
------------------------------------------------------------------------------------------------------------
overlay 
&spi1 {
    w25q16jv: w25q16jv@0 {
        compatible = "jedec,spi-nor";
        reg = <0>;
        spi-max-frequency = <2000000>;
        label = "w25q16jv";
        
    };
};
-------------------------------------------------------------------------------------------------------------
proj.conf

CONFIG_SPI=y

   

Working Capture for reading ID

My code output Capture 

Related