This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

spi clock problem

Hi,

I'm trying to use winbond spi flash (w25q64fv)

but i have a problem with spi as you can see in below image clock stop before receiving data from spi flash, do you have any idea why???

image description

here is what should i see based on datasheet

image description

here is my code for spi_master_init()

static void spi_master_init()
{
    uint32_t err_code = NRF_SUCCESS;

    // Configure SPI master.
    spi_master_config_t spi_config = SPI_MASTER_INIT_DEFAULT;

	spi_config.SPI_Pin_SCK  	= SPIM0_SCK_PIN;
	spi_config.SPI_Pin_MISO 	= SPIM0_MISO_PIN;
	spi_config.SPI_Pin_MOSI 	= SPIM0_MOSI_PIN;
	spi_config.SPI_Pin_SS   	= SPIM0_SS_PIN;

	spi_config.SPI_CONFIG_CPHA	= SPI_CONFIG_CPHA_Leading;
	spi_config.SPI_CONFIG_CPOL	= SPI_CONFIG_CPOL_ActiveHigh;
	
	spi_config.SPI_Freq			= SPI_FREQUENCY_FREQUENCY_K500;
	
    spi_config.SPI_CONFIG_ORDER = SPI_CONFIG_ORDER_MsbFirst;
	
    err_code = spi_master_open(SPI_MASTER_0, &spi_config);
    APP_ERROR_CHECK(err_code);

    // Register event handler for SPI master.
    spi_master_evt_handler_reg(SPI_MASTER_0, spi_master_0_event_handler);
}

void spi_master_0_event_handler(spi_master_evt_t spi_master_evt)
{
	// nothing
}

And here is my code for reading Status Register 1 (w25q64fv)

uint8_t readSR1() 
{ 
	uint8_t rx_data = 0x00;
	uint8_t tx_data[2] = {0x05, 0xff};
	
	spi_master_send_recv(SPI_MASTER_0, tx_data, 2, &rx_data, 1);
	
    return rx_data;
}
Related