1// You can write into flash page but can not over write erase page before write again.
2//https://stackoverflow.com/questions/47373317/how-to-write-erase-on-chip-flash-continuously-in-stm32f030-family
3uint32_t pageAddress = 0x08008000;
4 uint16_t buffer = 0xdddd; // data buffer
5 HAL_HAL_StatusTypeDef status;
6
7 while(1)
8 {
9 HAL_FLASH_Unlock(); // unlock the flash memory in ST
10 //FLASH_PageErase(pageAddress);
11 status=HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, pageAddress,
12 buffer);
13 HAL_FLASH_Lock(); // Flash memory locked
14 }
15