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

SPI_INTERFACE PROBLEM WITH EXTERNAL SERIAL FLASH

Hello,

I am using nRF5_SDK_15.2.0 and with s132_nrf52_6.0.0_softdevice

I am trying to interface with external Flash (MX25l64) using SPI.so when ever i am trying to send any command /data to external flash i am getting only zero in the receiving buffer.(pData) in my case.

for transferring i have used this call

err_code = nrf_drv_spi_transfer(&spi, &Byte, 1, pData, 1);
    APP_ERROR_CHECK(err_code);

void Spi_Init(void)
{
     ret_code_t err_code;
      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;
    err_code = nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL);
    APP_ERROR_CHECK(err_code);
    printf("\n\rSPI example started.  = %d \n",err_code);
    
}

here the err_code return value is always zero and Spi_init function return value is also zero.

it means it written NRF_SUCCESS as it is properly initilized and transferring data.

please help me to solve this issue.

Parents
  • Your code simply clocks one byte out, and reads whatever the chip outputs during this (command) byte. The value is not specfied in the datasheed IIRC.

    If one wants to actually read data, additional dummy bytes must be sent (0x00 should do).

    To read the status byte, the sequence should look more like this:

    err_code = nrf_drv_spi_transfer(&spi, pCmd, 2, pData, 2);

    And the actual status value will be in pData[1].

    SPI always reads and writes at the same time.

Reply
  • Your code simply clocks one byte out, and reads whatever the chip outputs during this (command) byte. The value is not specfied in the datasheed IIRC.

    If one wants to actually read data, additional dummy bytes must be sent (0x00 should do).

    To read the status byte, the sequence should look more like this:

    err_code = nrf_drv_spi_transfer(&spi, pCmd, 2, pData, 2);

    And the actual status value will be in pData[1].

    SPI always reads and writes at the same time.

Children
Related