How to read /Write data to NOR flash in nRF52840 dk?

Hi there,

I am developing a central in nrf52840 dk using SDK v2.0.0 in VS code. 

The BLE part is OK and it is possible me to get notifications.

Now, I need to store the notified data in to the flash.

Referring this: Nordic Semiconductor Infocenter , I understand that there is a 64MB external flash(MX25R6435F) in the DK.

It is possible me to find a sample code (from SDKv2.0.0) to read/ write data to flash.

The sample code worked fine for me. 

My notified data comprises of 2 bytes so that it is possible me to save upto 120 samples in a page(256 bytes).

Now I would like to know the following details:

1.How can I save large amount of data in different pages?

2. Is it possible to read and write data simultaneously (using different threads in FIFO manner)?

Thanks in Advance...

  • Hi

    I assume the sample application you're using is the JEDEC SPI-NOR project that lets you erase, write and read some bytes of data to see that they match and have been written correctly.

    1. It's a pretty simple project that have set up four bytes with the following line of code:

    const uint8_t expected[] = { 0x55, 0xaa, 0x66, 0x99 };
    And I guess the easiest way to write more is to edit the flash_write() function to add more data for example. I would also recommend checking out and implementing the QSPI driver and peripheral in nRF52840 as well as it increases the read/write throughput by a lot. 
    2. Reading and writing data at the same time is not possible I believe, as a pin should only do one thing at a time (input or output), what exactly is the plan here?
    Best regards,
    Simon
  • 1. It's a pretty simple project that have set up four bytes with the following line of code:

    const uint8_t expected[] = { 0x55, 0xaa, 0x66, 0x99 };
    And I guess the easiest way to write more is to edit the flash_write() function to add more data for example. I would also recommend checking out and implementing the QSPI driver and peripheral in nRF52840 as well as it increases the read/write throughput by a lot. 

    For my case the following is working:

    const uint16_t expected[] = { 0x189e, 0x199a, 0x010b, 0x187e,0x1234,0x187e, 0x199b,0x18b9 }; 
    What  I would like to know is ; does the data continuously save to the flash pages? or Does we need to provide each page offset all time?
  • ame time is not possible I believe, as a pin should only do one thing at a time (input or output), what exactly is the plan here

    I have around 256 bytes of data comes from my peripheral in a second. I need to send it to cloud server using a modem.

    To send this without data loss, I am trying to save the data in flash.

  • Hi

    I think you need to move to the next page once you fill one up so that you don't start overwriting the same page again.

    Best regards,

    Simon

Related