写操作:
void Write_Flash(unsigned int Flash_Addr,unsigned char Flash_Data)
{
Erase();
GIE=0;
CFGS=0;
PMADRL=Flash_Addr&0xFF;
PMADRH=(Flash_Addr>>8)&0xff;
FREE=0;
LWLO=1;
WREN=1;
PMDATL =Flash_Data;
LWLO=0;
UnLock();
DelayMS(2);
WREN=0;
GIE=1; }
读操作:
void Read_Flash(unsigned int Flash_Addr)
{
PMADRL=Flash_Addr&0xFF;
PMADRH=(Flash_Addr>>8)&0x3f;
CFGS=0;
RD=1;
_nop();
_nop(); //while(RD);
PROG_DATA_LO=PMDATL;
PROG_DATA_HI=PMDATH; }
为什么读出来的数据为FF
|