混沌的博客

少无适俗韵,性本爱丘山。 误落尘网中,一去三十年...... 久在樊笼里,不得返自然....

stm32f103 Flash 读写

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();
}
阅读更多
上一篇Could not write Ctrl/Stat register.
下一篇JTAG Timeout during adaptive clocking
想对作者说点什么? 我来说一句

STM32内部flash测试程序

2016年10月07日 330KB 下载

没有更多推荐了,返回首页

关闭
关闭