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

为什么我的EEPROM的程序有问题,高手们指点

请参考PE生成的代码:

/*
** ===================================================================
** Method : WriteSector (bean IntEEPROM)
**
** Description :
** The method writes the dword sector data to an EEPROM memory.
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static byte WriteSector(IEE1_TAddress AddrSec,dword Data32)
{
byte err; /* Temporary variable */

if (ESTAT_CBEIF == 0) { /* Is command buffer full ? */
return ERR_BUSY; /* If yes then error */
}
/* ESTAT: PVIOL=1,ACCERR=1 */
ESTAT = 48; /* Clear error flags */
*(volatile word *)(AddrSec) = (word)(Data32 >> 16); /* Array address and program data - higher part */
/* ECMD: ??=0,CMDB6=1,CMDB5=1,??=0,??=0,CMDB2=0,??=0,CMDB0=0 */
ECMD = 96; /* Sector modify command */
ESTAT_CBEIF = 1; /* Clear flag command buffer empty */
if ((ESTAT_PVIOL == 1)||(ESTAT_ACCERR == 1)) { /* Is protection violation or acces error detected ? */
return ERR_NOTAVAIL; /* If yes then error */
}
while (ESTAT_CBEIF == 0) {} /* Wait to buffer empty */
err=WriteWord(AddrSec + 2,(word)Data32); /* Write lower part */
if (err != ERR_OK) { /* Was attemp to write data to the given address errorneous? */
return err; /* If yes then error */
}
if (*(volatile word *)(AddrSec) != (word)(Data32 >> 16)) { /* Was attempt to write data to the given address errorneous? */
return ERR_VALUE; /* If yes then error */
}
return ERR_OK;
}

海纳百川  有容乃大
判断是否完成时这一句很关键:

if ((ESTAT_PVIOL == 1)||(ESTAT_ACCERR == 1)){}
海纳百川  有容乃大
返回列表