Board logo

标题: [求助] MC9S08AW60 FLASH擦写问题 [打印本页]

作者: 631753240    时间: 2008-10-24 08:35     标题: [求助] 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;
}


作者: strongchen    时间: 2008-10-29 16:26

对FLASH进行操作时应该将程序调入RAM中运行。




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0