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

How to send longer than 256 bytes in nRF52 spi list mode with nRF5_SDK_11?

Hi: Recently, I want to use nRF52 to read or write some data from a flash chip(w25q128bv) by using spi, I've read Manufactures ID correctly, also, I have wrote a register of the flash chip and read back correctly, that means spi communication is ok. However, when the length wrote or read is longer than 255 bytes, I do nothing. I know, the spi list mode could solve my problem, but I don't know how to use it, no details, no examples, making me in a mass.

Here, I list my code as an example, in this example, what I want is to program a page(256 bytes) of this flash chip, totally 260 bytes need be sent.(1 byte for page program command, 3 bytes for address, 256 bytes for a page data)

nrf_gpio_pin_clear(NOR_FLASH_CS);

xfer_desc.p_tx_buffer = buffer;

xfer_desc.p_rx_buffer = NULL;

xfer_desc.rx_length = 0;

xfer_desc.tx_length = 130;

flags = NRF_DRV_SPI_FLAG_HOLD_XFER                     |

           NRF_DRV_SPI_FLAG_TX_POSTINC             |

           NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER |

           NRF_DRV_SPI_FLAG_REPEATED_XFER;

ret = nrf_drv_spi_xfer(&spi, &xfer_desc, flags);

if (ret == NRF_SUCCESS)

{

      err_code = nrf_drv_ppi_channel_assign(m_flash_tx_ppi_channel,nrf_drv_spi_end_event_get(&spi), nrf_drv_spi_start_task_get(&spi));     

      APP_ERROR_CHECK(err_code);

      err_code = nrf_drv_ppi_channel_enable(m_flash_tx_ppi_channel);

      APP_ERROR_CHECK(err_code);

      nrf_spim_task_trigger(spi.p_registers, NRF_SPIM_TASK_START);

       err_code = nrf_drv_ppi_channel_disable(m_flash_tx_ppi_channel);

       APP_ERROR_CHECK(err_code);

}


nrf_gpio_pin_set(NOR_FLASH_CS);

I control cs pin and trig transfer manually, and do several experiment wiith different tx_length, however, this code didn't work. who can give me some suggestions or a reference?

Thank you very much!

Parents
  • I had the same problem and I managed to get it to work. Here are the details: devzone.nordicsemi.com/.../

  • Hi! Thanks for your answer. I waited for a long time so that I gave up. Actually, the design of nRF52 spi looks so bad. I'd try to solve my problem according your answer. Also, would you please post your correct spi code here? Thanks! I really don't read product specification, architecture manual and so on again.

Reply
  • Hi! Thanks for your answer. I waited for a long time so that I gave up. Actually, the design of nRF52 spi looks so bad. I'd try to solve my problem according your answer. Also, would you please post your correct spi code here? Thanks! I really don't read product specification, architecture manual and so on again.

Children
No Data