cancel
Showing results for 
Search instead for 
Did you mean: 

erase is not working in my board!!!

ouled
Associate
Posted on April 20, 2016 at 22:40

Hello everyone,

I'm developing a code in STM32F407VG. this code will erase the flash memory in a first step, and for a further work will upload a code into this memory.

this is my code for erasing the flash memory.

//unlocking the flash memoryif((FLASH->CR & 0x80000000) != 0x0) { FLASH->KEYR = 0x45670123; FLASH->KEYR = 0xCDEF89AB; }//clear the flagsFLASH->SR |= (0x80 | 0x40 | 0x20 | 0x2);// erase all pagesFLASH->CR |= 0x4 | 0x8000;FLASH->CR |= 0x10000; /* Disable the MER Bit */FLASH->CR &= ~(0x4 | 0x8000);// writing//locking flashFLASH_CR |= 0x80000000;

Please, give me where am I wrong.

(I should work directly with registers)

Thank you and Best Regards.

1 REPLY 1
slimen
Senior
Posted on April 21, 2016 at 14:43

Hi,

You can refer to this example which describes how to configure and use the FLASH HAL API to erase and program the internal FLASH memory:

STM32Cube_FW_F4_V1.11.0\Projects\STM324xG_EVAL\Examples\FLASH\FLASH_EraseProgram

If you are using Standard Peripherals Library, you can found this example in STM32F4xx_DSP_StdPeriph_Lib_V1.6.1 :

STM32F4xx_DSP_StdPeriph_Lib_V1.6.1\Project\STM32F4xx_StdPeriph_Examples\FLASH

It may be helpful for you to program the FLASH memory integrated.

Regards