SPIM nrf_drv_spi_transfer() with W25N01GVZEIR SPI Flash Memory

My setup is based on the SPI example program included in the nrfSDK nRF5_SDK_17.1.0_ddde560\examples\peripheral\spi\main.c
I've set up my SPI instance and am sending commands over to the Winbond flash memory.
However, I am only receiving 0x00 when I should be receiving the chip ID.
I've set the transfer and receive length to 5 as per this post:  SPIM nrf_drv_spi_transfer() usage
Since the command is 2 bytes long and I need to receive 3 bytes following.
You can see details of the SPI command on page 28 of the datasheet: https://www.winbond.com/resource-files/W25N01GV%20Rev%20O%20092619.pdf
I am wondering if I have set it up incorrectly or am not properly using the spi transfer function. 
static const nrf_drv_spi_t spi1 = NRF_DRV_SPI_INSTANCE(1);

static uint8_t cmd[5];
static uint8_t mfg_id[5];

void w25n01gv_init(void)
{
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SD_SPI_SS_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.frequency = NRF_DRV_SPI_FREQ_1M;
    //spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
    nrf_drv_spi_init(&spi1, &spi_config, spi_event_handler, NULL);
    NRF_LOG_INFO("SPI Initialized");
}

 
void w25n01gv_read_mfg_id(void)
{
    cmd[0] = 0x9F;
    cmd[1]=0x00; //dummy bit
    spi_xfer_done = false;
    nrf_drv_spi_transfer(&spi1, cmd, 5, mfg_id, 5);
    while(spi_xfer_done){
    }
    NRF_LOG_INFO("Manufacturer ID: 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", mfg_id[0], mfg_id[1], mfg_id[2], mfg_id[3], mfg_id[4]);
    NRF_LOG_FLUSH();
}
 

int main(void)
{
    log_init();

    w25n01gv_init();
    w25n01gv_read_mfg_id();
    while(1) {}
}
Parents Reply Children
  • Hello Simonr, thanks for the reply.
    (I typed this up two months ago yet never hit reply)
    I believe it should work the same since both devices displayed similarly in the logic analyzer.

    As you can see in the above screenshot of the logic analyzer it is transmitting the data over SPI, the ID code for the KV device is 0xEFAE21 and this is shown in the logic analyzer. 

    When sending the same command to the GV device the logic analyzer looks about the same except it receives the appropriate ID of 0xEFAA21.

    I've been working with the Winbond engineers as well and they have not seen this issue. I am led to believe it is an issue with the NRF52 device since the logic analyzer is showing what we would expect.

Related