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

Storing Data to flash memory

Hi

I am using the Nordic NRF52840_dk with SDK 16.

I want to store data to flash memory with Ble and uart enabled. I am using a external UART peripheral to receive data which, I then parse and broadcast via a ble advertisement.

However, I wish to store this data locally along with a start time for the logging. The data is received once per second. I want this stored inside a log which, I can later send to a mobile application.

I therefore, presume I need to use the flashwrite example. And my code is based on RTT.

I have a value stored as a string that comes in from a UART. I need to store this string in flash memory. I am presuming having a String array is a poor way to do it. Given that I have a requirement for logging for a day meaning 86400 entries of data.

What I want to happen is a command to be sent from the android app to start a log. And then a command to stop it.

Also for transmitting the data that is stored on Nordic board(when working). I am not sure if the nordic board is capable of making a bluetooth connection and, if not will making a Gatt connection.

  • If you set a breakpoint and then resume,  the softdevice will assert. That is fine, you just need to reset.

    Just set a breakpoint at the line memcpy, and right click config.p_data and click "add to watch". What this button is called depends on your IDE.

    If you are not able to see the content of the pointer, then you need to disable optimization in your project.If you are not sure how to do that, let me know what IDE you are using.

  • Im using segger.

    On the line:

      rc = fds_record_open(&desc, &config);//Read data

    How do I read the last entry. I presume the config that is in the flash is the default dummy one.

    So my question is what is desc? Is this the specfic instance that is read?

    Because I want to call a function that I can read the last record from. I will later need to read all the data. But I am thinking of doing this in a for loop from the first entry to the last.

  • Hello,

    Desc is the descriptor which is used to find and store values in records. config is the variable (fds_flash_record_t) that holds the actual flash data. You can check the definitions of these variable types in fds.h for an explanation.

    Have you seen the usage section on infocenter? It contains some pointers on how to use the records. So check out the variable types and this guide.

    Best regards,

    Edvin

Related