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

flash memory: too many pages are allocated

i want to know why there are 2 pages reserved although i mentioned i configured the number of pages to 1. It is used for what ? In fact, I need only one page for my data, but the pstorage reserve two pages. I have my data saved in 3B800. I want it in 3BC00, just the last page before bootloader Address (3C000). So I want to know the utility of "-1" in the following formula

#define PSTORAGE_DATA_START_ADDR    ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES - 1) \
                                * PSTORAGE_FLASH_PAGE_SIZE) 

Here is the code on my app :

    #define PSTORAGE_NUM_OF_PAGES       1                                                           /**< Number of flash pages allocated for the pstorage module excluding the swap page, configurable based on system requirements. */
#define PSTORAGE_MIN_BLOCK_SIZE     0x00004                                                      /**< Minimum size of block that can be registered with the module. Should be configured based on system requirements, recommendation is not have this value to be at least size of word. */

#define PSTORAGE_DATA_START_ADDR    ((PSTORAGE_FLASH_PAGE_END - PSTORAGE_NUM_OF_PAGES - 1) \
                                    * PSTORAGE_FLASH_PAGE_SIZE)                                 /**< Start address for persistent data, configurable according to system requirements. */
#define PSTORAGE_DATA_END_ADDR      ((PSTORAGE_FLASH_PAGE_END - 1) * PSTORAGE_FLASH_PAGE_SIZE)  /**< End address for persistent data, configurable according to system requirements. */
#define PSTORAGE_SWAP_ADDR          PSTORAGE_DATA_END_ADDR                                      /**< Top-most page is used as swap area for clear and update. */
Related