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

How to read&Write External Flash with NRF52832 SPI0 ?

Hi,

My problems are as follows:

SDK :nRF5_SDK_15.0.0_a53641a.

IDE:MDK 5.2.6

Chip:nrf52832  SPI0

External Flash :W25Q64

Now ,I can read the chip ID  correctly ,but when I transfer 256 bytes to External Flash ,as if only can write 251 bytes successfully, 

  • Is there something wrong with my code oprtion?
    Thank  you!

  • ...
Parents
  • Hi,

    The tx_buffer_length and rx_buffer_length parameters in nrf_drv_spi_transfer is declared as uint8_t, meaning it can only hold a length of 255 bytes. 

    ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance,
                                    uint8_t const * p_tx_buffer,
                                    uint8_t         tx_buffer_length,
                                    uint8_t       * p_rx_buffer,
                                    uint8_t         rx_buffer_length);

    There is a limitation of 255 bytes for the MAXCNT registers in SPIM peripherals with EasyDMA support, but legacy SPI peripheral should be able to send longer transfers (1 byte at the time, but the driver will support long transfers).

    If you want to use longer buffers, you can use the nrfx_spi driver. Note that the SPIM peripheral is limited to 255 bytes transfers in nRF52832, so you can not use the nrfx_spim driver.

    Best regards,
    Jørgen

Reply
  • Hi,

    The tx_buffer_length and rx_buffer_length parameters in nrf_drv_spi_transfer is declared as uint8_t, meaning it can only hold a length of 255 bytes. 

    ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance,
                                    uint8_t const * p_tx_buffer,
                                    uint8_t         tx_buffer_length,
                                    uint8_t       * p_rx_buffer,
                                    uint8_t         rx_buffer_length);

    There is a limitation of 255 bytes for the MAXCNT registers in SPIM peripherals with EasyDMA support, but legacy SPI peripheral should be able to send longer transfers (1 byte at the time, but the driver will support long transfers).

    If you want to use longer buffers, you can use the nrfx_spi driver. Note that the SPIM peripheral is limited to 255 bytes transfers in nRF52832, so you can not use the nrfx_spim driver.

    Best regards,
    Jørgen

Children
Related