首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助] MC9S08AW60 FLASH擦写问题

[求助] MC9S08AW60 FLASH擦写问题

FLASH的擦写要把代码拷到RAM中么?

下面是我的代码:

代码起始位置0XF000,擦写地址0x1A00,全速运行时为什么代码会跑飞啊?

请各位高人帮忙指点下

void flash(void)
{
byte temp;
FSTAT = FSTAT | 0x10;
FCDIV = 0x13;

if (FSTAT&0x10)//Check to see if FACCERR is set
{
FSTAT = FSTAT | 0x10; //write a 1 to FACCERR to clear
}

(*((volatile unsigned char *)(0x1A00))) = 0x00;
FCMD =0x40;
FSTAT_FCBEF = 1;
asm nop;
asm nop;
asm nop;
asm nop;
if (FSTAT&0x30)//check to see if FACCERR or FVIOL are set
{
//return 0xFF; //if so, error.
temp=0xff;
}
while (!(FSTAT&0x40)); //else wait for command to complete
asm nop;

delay(5000);

if (FSTAT&0x10)//Check to see if FACCERR is set
{
FSTAT = FSTAT | 0x10; //write a 1 to FACCERR to clear
}

(*((volatile unsigned char *)(0x1A00))) = 0x00;
FCMD = 0x20;
FSTAT_FCBEF = 1;
asm nop;
asm nop;
asm nop;
asm nop;

if (FSTAT&0x30)//check to see if FACCERR or FVIOL are set
{
//return 0xFF; //if so, error.
temp=0xff;
}
while (!(FSTAT&0x40)); //else wait for command to complete
asm nop;
asm JMP 0x18fd;
}

对FLASH进行操作时应该将程序调入RAM中运行。
海纳百川  有容乃大
返回列表