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

nRF52832 flash erase problem:cannot erase the third page

Hi,

Now I test flashwrite example using nRF52832 with software version V12.2.0. I want to erase all memory pages with the code bellow:

for(pg_num=0;pg_num<=pg_total_num;pg_num++)
   {
       addr = (uint32_t *)(pg_size * pg_num);  //pg_size=4096 Bytes
       flash_page_erase(addr);
       
   }

But the erase fails when pg_num=3. I also have tested the other pages and all of them can be erased successfully except page 3.

What is the problem? Why I cannot erase page 3? Looking forward to your reply.

Thanks!

Best Regards Ye Chengyang

Parents
  • would you try these and pg_size is 1024 Words

    #define PAGE_SIZE_WORDS 1024
    
    // Retrieve the address of a page.
    static uint32_t const * address_of_page(uint16_t page_num)
    {
        return fs_config.p_start_addr + (page_num * PAGE_SIZE_WORDS);
    }
    
    void m_flash_erase_page_0(void)
    {
    	  erase_flag=1;
    	  // Erase one page (page 0).
        fs_ret_t ret = fs_erase(&fs_config, address_of_page(0), 1, NULL);
        if( ret != FS_SUCCESS )
        {
            NRF_LOG_INFO("fs_erase error\r\n");
        }
    		 while(erase_flag == 1) { power_manage(); }
    }
    
Reply
  • would you try these and pg_size is 1024 Words

    #define PAGE_SIZE_WORDS 1024
    
    // Retrieve the address of a page.
    static uint32_t const * address_of_page(uint16_t page_num)
    {
        return fs_config.p_start_addr + (page_num * PAGE_SIZE_WORDS);
    }
    
    void m_flash_erase_page_0(void)
    {
    	  erase_flag=1;
    	  // Erase one page (page 0).
        fs_ret_t ret = fs_erase(&fs_config, address_of_page(0), 1, NULL);
        if( ret != FS_SUCCESS )
        {
            NRF_LOG_INFO("fs_erase error\r\n");
        }
    		 while(erase_flag == 1) { power_manage(); }
    }
    
Children
No Data
Related