我使用的是U2编程器。
我也是将page address设定从0xF000开始,但烧入后总不成功
我只试着只写一个byte,就出现之前的问题
///////////////////////////////////////////////////////////////
#define ReadCommand 0x01
#define PrgCommand 0x02
#define EraseCommand 0x03
#define PerSector 512
#define waittime 0x02
void G516Flash_enable(void)
{
ISPCR=ISPCR & 0x18;
ISPCR=ISPCR | waittime;
ISPCR=ISPCR | 0x80;
}
void Do_IAP()
{
G516Flash_enable();
SCMD=0x46;
SCMD=0xB9;
_nop_();
}
void G516Flash_page_erase(int page_address)
{
IFMT=IFMT & 0xf8;
IFMT=IFMT | EraseCommand;
IFADRH=(uchar)(page_address>>8);
IFADRL=(uchar)(page_address&0x00FF);
Do_IAP();
}
void G516Flash_byte_program(int byte_address, char dta)
{
IFMT=IFMT & 0xf8;
IFMT=IFMT | PrgCommand;
IFADRH=(uchar)(byte_address>>8);
IFADRL=(uchar)(byte_address&0x00FF);
IFD=dta;
Do_IAP();
}
char G516Flash_byte_read(int byte_address)
{
IFMT=IFMT & 0xf8;
IFMT=IFMT | ReadCommand;
IFADRH=(uchar)(byte_address>>8);
IFADRL=(uchar)(byte_address&0x00FF);
Do_IAP();
return(IFD);
}
///////////////////////////////////
void save()
{
G516Flash_page_erase(0xf000);
G516Flash_byte_program(0xf000,data[16]);
}
void read()
{
G516Flash_byte_read(0xf000);
data[16]=IFD;
}
代码有问题么?
|