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

How to handle flashwrit in an safe way.

Hi,

i need to store data in my Flash, for that i use the flashwrite example. Am i right taht i can use the remain of my application flash? So all flash = 256 kB - App = 20 kB = Flash i can use to write my Data to ?

I read that if i use flashwrite and the Softdevie, that i have to halt the Softdevie becauose of the latncy of flahswriting is that right? How can i handle this in a safe way?

Best reagrds Nils

  • Hi Ole,

    thanks for your feedback.

    So normaly i can define my first address where i want to write the first Data is that right becouse my Application Code is also static thes address would be the same every time?

    And then i can right data to it like in the example of your SDk with an increment of the address.

    How do i know if the page i am writing to is full and how can i go to the next page or is this automatically done?

    best regards Nils

  • Hi,

    in the moment it is not possible for me to write an application which writes data to the Flash in a savety way. The best thing would be an example how to programm Log-File-Data to the memory. Maybe this will not be possible to get this example so i have to write it be my self, but for that i need to understand what i have to to to write in a savety way to the Flash.

    Do i understand this correctly,in the example of SDK tha Data will be written on the Last Page every Time again and again ? And after the Page is full it begins at the start adress again? But this is not the way i want to use it, i need to write as much as possible into the Flash, not only to one Page.

    Please Nordic give me Some more support, i really try to understand but its hard for me, more examples would be great,

    Thank you and best regards nils

  • Hi Nils,

    I think you're asking two things:

    (1) How to erase* and write to Flash (2) How to construct and erase a circular/ring buffer

    *I'm preempting what's coming next. IIRC, you need to erase the Flash page at least once every two write cycles.

    I would say it's reasonable to ask for support on the first question, but the second question is a bit of stretch as it's a generic programming issue. Unfortunately, I can't share our code to do it as we consider it proprietary, but there're some examples of how to do this on the Interweb. For example:

    http://www.embedded.com/electronics-blogs/embedded-round-table/4419407/The-ring-buffer

    Note: the example is a simple ring buffer, but the contents of a ring buffer itself can easily be a struct that contains your datatypes.

    -m

  • There is no silver bullet when it comes to flash writing, and you will have to keep track of a lot of details yourself. Marc is quite correct below, we're happy to help you, but we can not and will not do the implementation for you.

    I do believe that you've gotten the information you need to do this implementation, but if anything in particular is unclear, I can try to elaborate. I've tried clearing up a few things below:

    • As long as you don't do a recompile, the size of your application will not change.
    • There is no magic way to know if a particular flash address have been written or not, but newly erased flash will always have the value 0xFF. If the value is 0xFF, you can therefore most likely assume that it isn't written, although 0xFF could of course also be the value that was written. This is often overcome by using framing bytes, adding CRC and block sizes or similar.
    • There is no automatic way to know if a page is full, or to progress to the next page. You have to monitor the address you write to yourself, and handle this in your application, either to erase the same page or start writing to the next page.
Related