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

Problem Interfacing SPI external Flash and writing to the Flash Registers

Hi,

I am trying to interface  External Flash (IS25LP064A ) using SPI example in SDK v16. I am able to read the Manufacturer_ID and the device ID from the external flash. Now I want to Read, write and Erase the flash. But I am unable to do so. Please tell me if any example is there or the way how to do that .

Please give any example code to interface SPI flash.

Parents
  • Hi Mushtakh, 

    Unfortunately, I don't think we have an example for that flash. You would have to set up the SPI interface yourself using the SPI master driver ideally and implement the functions you need from the device as described in the datasheet. This post and this might give some inspiration. 

    -Amanda H.

  • Thanks Amanda, I have already seen that posts. But I am unable to enable write and hence unable to write the data as well. This is my code. Can u please help and let me know what is missing term I am unable to get.    I am using nRF SDK v16.0 I am able to set up SPI and also I can read the device ID and Manufacturer ID.

    void write_enable()
    {
        ret_code_t err_code;
        uint8_t status_register;
        spi_xfer_done = false;
        static uint8_t spi_tx_cmd[1];
        cs_low();
        uint8_t WREN = 0x06;
        spi_tx_cmd[0] = WREN;
    
    
    //  nrf_drv_spi_transfer(&spi,(uint8_t const *)spi_tx_cmd,sizeof(spi_tx_cmd),0,0);
    
        err_code = nrf_drv_spi_transfer(&spi,spi_tx_cmd,sizeof(spi_tx_cmd),m_buffer_rx,1);
           printf("Write_enable_err_code : %d\n",err_code);
    
        if(err_code == NRF_SUCCESS)
        {
           printf("WREN Transfer Successful\n");
        }
        while(spi_xfer_done == false)   {}
    
        status_register = read_status_register();
        printf("Status after WREN: %d\r\n", status_register);
    
        cs_high();
    
        printf("Flash Write Enable Latch operation successful\n");
    }
    

Reply
  • Thanks Amanda, I have already seen that posts. But I am unable to enable write and hence unable to write the data as well. This is my code. Can u please help and let me know what is missing term I am unable to get.    I am using nRF SDK v16.0 I am able to set up SPI and also I can read the device ID and Manufacturer ID.

    void write_enable()
    {
        ret_code_t err_code;
        uint8_t status_register;
        spi_xfer_done = false;
        static uint8_t spi_tx_cmd[1];
        cs_low();
        uint8_t WREN = 0x06;
        spi_tx_cmd[0] = WREN;
    
    
    //  nrf_drv_spi_transfer(&spi,(uint8_t const *)spi_tx_cmd,sizeof(spi_tx_cmd),0,0);
    
        err_code = nrf_drv_spi_transfer(&spi,spi_tx_cmd,sizeof(spi_tx_cmd),m_buffer_rx,1);
           printf("Write_enable_err_code : %d\n",err_code);
    
        if(err_code == NRF_SUCCESS)
        {
           printf("WREN Transfer Successful\n");
        }
        while(spi_xfer_done == false)   {}
    
        status_register = read_status_register();
        printf("Status after WREN: %d\r\n", status_register);
    
        cs_high();
    
        printf("Flash Write Enable Latch operation successful\n");
    }
    

Children
Related