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

Having issue to read manufacturer ID from SPI flash memory

Hello Nordic Team

I am working on SDK v-17.0.2 SPI example to interface with external flash memory. I have Winbond W25Q128FV and Fudan FM25Q08 flash memory but have same issue to read manufacturer ID. I am getting 0x00 in response.

I attached test code below:

/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;
    NRF_LOG_INFO("Transfer completed.");
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(" Received:");
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    spi_config.mode = NRF_DRV_SPI_MODE_3;
    spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
    spi_config.frequency = NRF_DRV_SPI_FREQ_1M;
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

    NRF_LOG_INFO("SPI example started.");

    while (1)
    {
        m_tx_buf[0] = 0x90;
        m_tx_buf[1] - 0x00;
        m_tx_buf[2] = 0x00;
        m_tx_buf[3] = 0x00;

        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;

        APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, 4, m_rx_buf, 6));

        while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();

        bsp_board_led_invert(BSP_BOARD_LED_0);
        nrf_delay_ms(200);
    }
}

I am stuck here and trying since 2 days but no luck. Any help or right direction on this will be great.

Thanks and Regards

Raj

Parents
  • The SPI nor-flash ID is located the last page in last bytes. For example as follow code( 2M bytes):

    #define Flash_Sector 4*1024
    #define Flash_Block 16*4*1024
    #define Flash_SIze 0x200000//size=2MB BYTE (Flash_Block*32)
    #define Flash_ID_addres (Flash_SIze-16) 

    u8 GetNorFlashID(void)
    {//RDID c2 24 15 //RES Command 24 //REMS/REMS2/REMS4/ Command c2 24

    u8 u8FlashID[8];
    //char tt[128];
    CMD_RDID(u8FlashID);
    //sprintf(tt,"\nmsAPI_FlashID= 0x%x,0x%x,0x%x \r\n",(u16)u8FlashID[0],(u16)u8FlashID[1],(u16)u8FlashID[2]);
    //Putstring(tt);

    if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x15) //MX25L1633E
    u8FlashType = MX25L1633E;
    else if (u8FlashID[0]==0xc2 && u8FlashID[1]==0x20 && u8FlashID[2]==0x15) //W25Q16BV
    u8FlashType = MX25L1606E;
    else if (u8FlashID[0]==0xEF && u8FlashID[1]==0x40 && u8FlashID[2]==0x15) //W25Q16BV
    u8FlashType = W25Q16DV;
    else if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x16) //MX25L3205D
    u8FlashType = MX25L3205D;
    else if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x17) //MX25L6405
    u8FlashType = MX25L6405;
    else if (u8FlashID[0]==0x1F && u8FlashID[1]==0x46 && u8FlashID[2]==0x01) //AT26DF161A
    u8FlashType = AT26DF161A;
    else if (u8FlashID[0]==0x1F && u8FlashID[1]==0x47 && u8FlashID[2]==0x00) //AT26DF321 or AT25DF321
    u8FlashType = AT2xDF321;
    else if (u8FlashID[0]==0x1C && u8FlashID[1]==0x34 && u8FlashID[2]==0x16) //EN25M32
    u8FlashType = EN25M32;
    else if (u8FlashID[0]==0xEF && u8FlashID[1]==0x40 && u8FlashID[2]==0x16) //W25Q32BV
    u8FlashType = W25Q32BV;
    else //other flash
    u8FlashType = INVALID_FLASH;
    return u8FlashType;
    }

    You may take for reference. 

Reply
  • The SPI nor-flash ID is located the last page in last bytes. For example as follow code( 2M bytes):

    #define Flash_Sector 4*1024
    #define Flash_Block 16*4*1024
    #define Flash_SIze 0x200000//size=2MB BYTE (Flash_Block*32)
    #define Flash_ID_addres (Flash_SIze-16) 

    u8 GetNorFlashID(void)
    {//RDID c2 24 15 //RES Command 24 //REMS/REMS2/REMS4/ Command c2 24

    u8 u8FlashID[8];
    //char tt[128];
    CMD_RDID(u8FlashID);
    //sprintf(tt,"\nmsAPI_FlashID= 0x%x,0x%x,0x%x \r\n",(u16)u8FlashID[0],(u16)u8FlashID[1],(u16)u8FlashID[2]);
    //Putstring(tt);

    if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x15) //MX25L1633E
    u8FlashType = MX25L1633E;
    else if (u8FlashID[0]==0xc2 && u8FlashID[1]==0x20 && u8FlashID[2]==0x15) //W25Q16BV
    u8FlashType = MX25L1606E;
    else if (u8FlashID[0]==0xEF && u8FlashID[1]==0x40 && u8FlashID[2]==0x15) //W25Q16BV
    u8FlashType = W25Q16DV;
    else if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x16) //MX25L3205D
    u8FlashType = MX25L3205D;
    else if (u8FlashID[0]==0xC2 && u8FlashID[1]==0x24 && u8FlashID[2]==0x17) //MX25L6405
    u8FlashType = MX25L6405;
    else if (u8FlashID[0]==0x1F && u8FlashID[1]==0x46 && u8FlashID[2]==0x01) //AT26DF161A
    u8FlashType = AT26DF161A;
    else if (u8FlashID[0]==0x1F && u8FlashID[1]==0x47 && u8FlashID[2]==0x00) //AT26DF321 or AT25DF321
    u8FlashType = AT2xDF321;
    else if (u8FlashID[0]==0x1C && u8FlashID[1]==0x34 && u8FlashID[2]==0x16) //EN25M32
    u8FlashType = EN25M32;
    else if (u8FlashID[0]==0xEF && u8FlashID[1]==0x40 && u8FlashID[2]==0x16) //W25Q32BV
    u8FlashType = W25Q32BV;
    else //other flash
    u8FlashType = INVALID_FLASH;
    return u8FlashType;
    }

    You may take for reference. 

Children
No Data
Related