我目前正在做一个涉及 TLE9879 MCU 的项目,我遇到了擦除代码中一页代码闪存的问题。 奇怪的是,我能够成功地对其进行编程,但在尝试擦除时却遇到了故障。
如果能就这种差异的潜在原因提出任何见解或建议,我将不胜感激。 你在这方面的专业知识和指导将非常宝贵。
谢谢
马里奥
这是我的主要
int main(空白)
{
int i;
uint8 *p;
静态 uint16 校验和,数据;
/* 基于配置向导配置初始化硬件模块*/
tle_init ();
校验和 = 0;
/****************************************************************************
wdt1_sow_Service (1u);
if (USER_CFLASH_WR_PROT_DIS (0) == 0)
{
//code flash 不再受写保护
Port_ChangePin(LED 4,PORT_AC
tiON_SET);
}
其他
{
//code flash 仍然写入保护,密码不匹配
Port_ChangePin(LED 5,PORT_ACTION_SET);
}
/****************************************************************************
uint8 资源;
wdt1_sow_Service (1u);
res = USER_ERASEPG ((uint32*) progFlashStart + 0x8000,0);
(void) wdt1_Service ();
如果 ((res 1) == 1)
{
//擦除失败
Port_ChangePin(LED 1,PORT_ACTION_SET);
}
/****************************************************************************
/* uint8 page_data [128];
for (i = 0; i < flashPageSize; i++)
{
page_data [i] = i;
}
wdt1_sow_Service (1u);
if(ProgramPage(progFlashStart + 0x8000,p age_data,0,0,0)== 1)
{
USER_ERASEPG ((uint32*) progFlashStart + 0x8000,0);
}
(void) wdt1_Service ();*/
/****************************************************************************
tuser_openab openab_res;
openab_res.reg = USER_OPENAB (progFlashStart + 0x20000);
(void) wdt1_Service ();
如果 (openab_res.bit.execFail == 1)
{
Port_ChangePin(LED 2,PORT_ACTION_SET);
//程序集缓冲区已经打开,或者
//嵌套的 NVM 操作
}
如果 (openab_res.bit.abFail == 1)
{
Port_ChangePin(LED 3,PORT_ACTION_SET);
//数据闪存写入保护,或
//错误的 nvmPageAddr 地址,不在闪存范围内
}
/****************************************************************************
/* 擦除数据闪存扇区*/
nvm_Error = USER_ERASEPG ((uint32*) dataFlashStart,0);
(void) wdt1_Service ();
/* 检查扇区擦除是否通过*/
如果 (nvm_Error == 0u)
{
/* 擦除扇区期间发生错误 */
Port_ChangePin(LED 1,PORT_ACTION_SET);
}
其他
{
/* 擦除扇区期间发生错误 */
Port_ChangePin(LED 8,PORT_ACTION_SET);
}
对于 (;;)
{
(void) wdt1_Service ();
}
}