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

Use of pre incrementer in flashwrite example

Hello All,

I was looking at the flash writewrite_example and the starting address is defines as:

addr = (uint32_t *)(pg_size * pg_num);

Later in the code, the example writes to flash using the following function call:

flash_word_write(++addr, (uint32_t)patwr);

This will pass the next address into the example. Does this mean that the starting address is actually:

addr = (uint32_t *)((pg_size * pg_num)+1);

If not, does the example code produce an off by 1 error when reading? I am really just trying to confirm the starting address to write to in the last page in flash. I am going to store some values there.

On a side note, can anyone tell me when the Bond Manager will be used? I don't believe I using it, unless it is called under the hood by the softdevice code.

Parents
  • I believe that the code that implemented flash_word_write and related functions for that example stored a "magic number" as the first thing in each flash page written as an error check. So the pre-increment is probably a way of stepping over that.

    That said, if you are using one of the newer SDKs like 5.2.0, you should consider using the pstorage API to store and recover information from the flash. It hides a lot of the complexity for you.

    I do not know enough about the bond manager to help you with that question.

Reply
  • I believe that the code that implemented flash_word_write and related functions for that example stored a "magic number" as the first thing in each flash page written as an error check. So the pre-increment is probably a way of stepping over that.

    That said, if you are using one of the newer SDKs like 5.2.0, you should consider using the pstorage API to store and recover information from the flash. It hides a lot of the complexity for you.

    I do not know enough about the bond manager to help you with that question.

Children
Related