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 are my code for erasing the flash memory. Please, give me where am I wrong. (I should work directly with registers)
//unlocking the flash memory if((FLASH->CR & 0x80000000) != 0x0) { FLASH->KEYR = 0x45670123; FLASH->KEYR = 0xCDEF89AB; } //clear the flags FLASH->SR |= (0x80 | 0x40 | 0x20 | 0x2); // erase all pages FLASH->CR |= 0x4 | 0x8000; FLASH->CR |= 0x10000; /* Disable the MER Bit */ FLASH->CR &= ~(0x4 | 0x8000); // writing //locking flash FLASH_CR |= 0x80000000;
Thank you. Best regards.