//*******************************************************************************
//FLASH写入全部采用32的字写入和读出来
//*******************************************************************************
void RdFlash(unsigned char *RamAdr,unsigned int ROM,unsigned int Number){
DATA_EEPROM_Unlock(); //解锁FLASH
memcpy(RamAdr,(unsigned char *)ROM,Number);
DATA_EEPROM_Lock(); //解锁FLASH
}
//***********************************************************************************
//传入的Number是字节!
void WrFlash(unsigned int *RamAdr,unsigned int ROM,unsigned int Number){
unsigned int i;
谢谢 已经可以了 下载完成
STM32的FLASH 的操作
简单化!
*******************************************************************************/
#include "use.h"
//*******************************************************************************
//FLASH写入全部采用32的字写入和读出来
//*******************************************************************************
void RdFlash(unsigned char *RamAdr,unsigned int ROM,unsigned int Number){
DATA_EEPROM_Unlock(); //解锁FLASH
memcpy(RamAdr,(unsigned char *)ROM,Number);
DATA_EEPROM_Lock(); //解锁FLASH
}
//***********************************************************************************
//传入的Number是字节!
void WrFlash(unsigned int *RamAdr,unsigned int ROM,unsigned int Number){
unsigned int i;
DATA_EEPROM_Unlock(); //解锁FLASH
//****************************************************************
for(i=0;i<Number/4;i++){ //按字操作
if( *(unsigned int *)ROM != *RamAdr){//数据不相等,就要改写!
DATA_EEPROM_EraseWord(ROM);
FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR
| FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);
DATA_EEPROM_ProgramWord(ROM,*RamAdr);//*RamAdr
}
RamAdr++;
ROM +=4; //数据只能加1
}
DATA_EEPROM_Lock(); //锁FLASH
}
一周热门 更多>