关闭

stm32f103 Flash 读写

标签: stm32
1698人阅读 评论(0) 收藏 举报
分类:
const static uint32_t FLASH_START_ADDRESS = 0x0800FC00;
//f103c8t6 The last page(63) 0x0800FC00-0x0800FFFF
volatile FLASH_Status FLASHStatus = FLASH_COMPLETE;
uint32_t ReadFlash(uint32_t offset)
{
      uint32_t *pData = 0;
      pData = (uint32_t*)(FLASH_START_ADDRESS + offset);     
      return *pData;
}

void WriteFlash(uint32_t offset, uint32_t Data)
{
      FLASH_Unlock();
      FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); 
      FLASHStatus = FLASH_ErasePage(FLASH_START_ADDRESS);
      if(FLASHStatus == FLASH_COMPLETE){
           FLASHStatus = FLASH_ProgramWord(FLASH_START_ADDRESS + offset, Data);
      //   FLASHStatus = FLASH_ProgramWord(StartAddress+4, 0xA234567B);812
      }
      FLASH_Lock();
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:736285次
    • 积分:11406
    • 等级:
    • 排名:第1441名
    • 原创:457篇
    • 转载:83篇
    • 译文:1篇
    • 评论:125条
    最新评论