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

sd_flash_page_erase.

I am trying to save data to the flash memory.  My starting file is the ble_app_uart_pca10040 (s132). I am using the sd_flash_write address is 0x007ffd0 and a value of 0; I then use uint16_t value1 = *(uint16_t *)ADDRESS_ADR which is set to 0x7ffdo. I have verified that the write and read work! Now I need to erase the flash so I can use it again! I have tried page numbers (1 through 3) and it has not work! I would really like to just erase one 32 bit area od the flash! (And have the code as simple as possible!

Thanks!

Mike

Parents
  • Hi,

    Pages 1-3 are in the softdevice region in flash. You will not be able to erase these pages, as they are protected. Address 0x0007ffd0 should be on page 127, see figure 1 in Memory documentation in PS.

    Best regards,
    Jørgen

  • At first did not appear to work!

    This is in the Routine that is called when I send my value to trigger the erase:

     printf("\r Before Flash \r\n");
                          printf("%#08x\n",value );
                          printf("\r   Done \r\n");  

             sd_flash_page_erase(127);
                       /**  flash_write(ADDRESS_ADR,Val1);  */       /** This works but writes from 0x007ffd0 to 0X007ffd3 */
                                                                     /** OR 0X007ffd4 to 0X007ffd7   It writes to Four Locations */

                    uint16_t value1 = *(uint16_t *)ADDRESS_ADR;              /** Display what is stored at memory location STORAGE_Add */
                    printf("\r After Flash Value \r\n");
                    printf("%#08x\n",value1 );
                    printf("\r   Done \r\n"); 

    This is what is viewed when the Erase is activated:

     Before Flash
    0x000000
       Done
     After Flash Value
    0x000000
       Done

    When I run the program again this is what displayed:

     Before Flash
    0x00ffff
       Done
     After Flash Value
    0x00ffff
       Done

    So there must be a delay for it to finish the erase! Is there a command or something simple to delay until it has finished

Reply
  • At first did not appear to work!

    This is in the Routine that is called when I send my value to trigger the erase:

     printf("\r Before Flash \r\n");
                          printf("%#08x\n",value );
                          printf("\r   Done \r\n");  

             sd_flash_page_erase(127);
                       /**  flash_write(ADDRESS_ADR,Val1);  */       /** This works but writes from 0x007ffd0 to 0X007ffd3 */
                                                                     /** OR 0X007ffd4 to 0X007ffd7   It writes to Four Locations */

                    uint16_t value1 = *(uint16_t *)ADDRESS_ADR;              /** Display what is stored at memory location STORAGE_Add */
                    printf("\r After Flash Value \r\n");
                    printf("%#08x\n",value1 );
                    printf("\r   Done \r\n"); 

    This is what is viewed when the Erase is activated:

     Before Flash
    0x000000
       Done
     After Flash Value
    0x000000
       Done

    When I run the program again this is what displayed:

     Before Flash
    0x00ffff
       Done
     After Flash Value
    0x00ffff
       Done

    So there must be a delay for it to finish the erase! Is there a command or something simple to delay until it has finished

Children
No Data
Related