void FLASH_Erase(void)//擦除程序必须变成ff才可以
{
uint32_t EraseCounter;
fmc_unlock();
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);
for(EraseCounter = 0U; EraseCounter < PageNum; EraseCounter++)
{
fmc_page_erase(FMC_WRITE_START_ADDR + (FMC_PAGE_SIZE * EraseCounter));
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);
}
fmc_lock();
}
void FLASH_Write(uint32_t DATA_32)//写入FLASH
{
// FLASH_Erase();
fmc_unlock();
address = FMC_WRITE_START_ADDR;
while(address < FMC_WRITE_END_ADDR)
{
fmc_word_program(address, DATA_32);
address += 4U;
fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);
}
fmc_lock();
}
uint32_t FLASH_Read_only(void)//只读
{
uint32_t Date_Read=0;
Date_Read = (*(uint32_t *)FMC_WRITE_START_ADDR);
return Date_Read;
}
|