在线时间0 小时
UID349843
注册时间2012-3-28
NXP金币0
该用户从未签到
新手上路

- 积分
- 9
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2013-3-22 10:24:04
|
显示全部楼层
回复:MC9S08 DZ60 写EEPROM时FSTAT_FCBEF=1;不执行直接跳过
回复第 4 楼 于2013-03-22 09:18:59发表:
如下是MC9S08DZ flash操作的参考代码
unsigned char Flash_Cmd(unsigned int FlashAddress, unsigned int FlashDataCounter, unsigned char* pFlashDataPtr, unsigned char FlashCommand)
{
/* Clear Flags if set*/
FSTAT = 0x30;
do
{
/* Wait for the Last Busrt Command to complete */
while(!(FSTAT&0x80));
/* Write Data into Flash*/
(*((volatile unsigned char *)(FlashAddress++))) = *pFlashDataPtr;
pFlashDataPtr++;
/* Write Command */
FCMD = FlashCommand;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
/* Put FCBEF at 1 */
FSTAT = 0x80;
/* Check if Flash Access Error or Protection Violation Error are Set */
if (FSTAT&0x30)
{
/* If so, finish the function returning 1 to indicate error */
return (1);
}
}while (--FlashDataCounter);
/* wait for the last command to complete */
while ((FSTAT&0x40)==0);
/* Return zero to indicate that the function executed Ok */
return (0);
}
还是不行 我仿真的时候发现FCMD寄存器的值一直0 写指令代码后没变化 这个情况是怎么回事 是正常的吗 |
|