cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103, erase a function that define in spesial section

mn
Associate III
Posted on May 28, 2015 at 11:13

hi

in my software, define a section named ''My_SECTION'' and put just a function on it.

in IAR .icf file define that section write in address 0x08050000.

I used debugger, function is correctly wrote in 0x08050000 and has 16 byte length. All other functions are wrote from address 0x08003000.

when MCU power on , In main() function, I want to erase function that wrote in address 0x08050000. when erase page at address

0x08050000, page doesn't erase, but if erase just page after or before that, it is erase correctly . I think pages that programed, is locked.

Is it possible to erase a page that some of execution code write on it?

#flash #stm32f103 #erase
3 REPLIES 3
Posted on May 28, 2015 at 16:04

Should erase the same way any other sector.

You'd want to double check if you have write protected any of the sectors, and that you are correctly unlocking, and clearing pending status.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mn
Associate III
Posted on May 30, 2015 at 05:51

my erase function:

    FLASH_Unlock();

    delay_us(100);    

    FLASHStatus = FLASH_ErasePage(PgAdd);

-----

this code execute from flash memory and correctly erase pages 0x08050800 and 0x0804f800;

mn
Associate III
Posted on May 30, 2015 at 11:39

OK, thanks clive1.

when i use this code:

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_In);

    FLASH_Unlock();

    FLASH_ErasePage(0x50000);

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_Out);

//-----------------

Buffer_Out equal Buffer_In, page does not erase.

but when use below code page

erase correctly

:

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_In);

    FLASH_Unlock();

    FLASH_ErasePage(0x50000);

    FLASH_Lock();  // difference

with above code.

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_Out);

//------------