Board logo

标题: [求助]9s12dg128 flash擦除 [打印本页]

作者: wkx11    时间: 2008-6-3 10:52     标题: [求助]9s12dg128 flash擦除

请问版主我在对9s12dg128的flash地址$ff00-$ffff进行擦除操作的时候总是会出现程序跳转是怎么回事呀。

[此贴子已经被作者于2008-6-3 11:11:42编辑过]


作者: wkx11    时间: 2008-6-3 10:54

擦除函数是这样的
byte EraseSector(word Addr)
{
EnterCritical(); /* Enter critical section */
ClearFlags();
FCNFG_BKSEL=0; /* Clear all flags */
//SelectBank(Addr); /* Select bank and page */
if (FSTAT_CBEIF == 0) { /* Is command buffer full ? */
ExitCritical(); /* Exit critical section */
return ERR_BUSY; /* If yes then error */
}
*(word *) Addr = IFsh1_DummyData; /* Write eny word to FLASH buffer */
FCMD = 64; /* Initiate Sector Erase commamd */
FSTAT = 128;
asm { /* Jump to Wait in RAM code */
JSR WaitInRAMcode1
} /* Clear flag command buffer empty */
if ((FSTAT_PVIOL == 1)||(FSTAT_ACCERR == 1)) { /* Is protection violation or access error detected ? */
ExitCritical(); /* Exit critical section */
return ERR_NOTAVAIL; /* If yes then error */
}
FCNFG_CCIE = 1; /* Enable interrupt */
while (FSTAT_CBEIF == 0); /* Wait to buffer empty */
while (FSTAT_CCIF == 0); /* Wait to command complete */
ExitCritical(); /* Exit critical section */
return ERR_OK; /* OK */
}
版主看看这段代码有什么需要改的么?





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