我用的万利EK-STM32F,我的板子上装的STM32F103R8T6(64脚的),一直写入都很正常,我现在在编Flash读写(准备把他当eeprom用,能当eeprom用吗?我正在试), if (((YT_Address & 0x01)!=0x01)&((YT_Address & 0xff)==0xff)) { /* Unlock the Flash Program Erase controller */ FLASH_Unlock();
/* Define the number of page to be erased */ NbrOfPage = (EndAddr - StartAddr) >> 10;
/* Clear All pending flags */ FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
/* Erase the FLASH pages */ FLASHStatus = FLASH_ErasePage(StartAddr + PageSize); YT_Address=0x00000001; Data=0x15012009; if(FLASHStatus == FLASH_COMPLETE)FLASHStatus = FLASH_ProgramWord(StartAddr+PageSize, YT_Address); if(FLASHStatus == FLASH_COMPLETE)FLASHStatus = FLASH_ProgramWord(StartAddr+PageSize+4, Data); if((*(vu32*)(StartAddr+PageSize)) != YT_Address)MemoryProgramStatus = FAILED; if((*(vu32*)(StartAddr+PageSize+4)) != Data)MemoryProgramStatus = FAILED; FLASH_Lock(); } 结果就死机,再也写不起了。
|