📜  如何在stm32f030中写入闪存——C编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:41.653000             🧑  作者: Mango

代码示例1
// You can write into flash page but can not over write erase page before write again.
//https://stackoverflow.com/questions/47373317/how-to-write-erase-on-chip-flash-continuously-in-stm32f030-family
uint32_t pageAddress = 0x08008000;
  uint16_t buffer = 0xdddd;          // data buffer
  HAL_HAL_StatusTypeDef  status;

  while(1)
  { 
     HAL_FLASH_Unlock();              // unlock the flash memory in ST
     //FLASH_PageErase(pageAddress); 
     status=HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, pageAddress, 
     buffer);
     HAL_FLASH_Lock();                // Flash memory locked
  }