I am using 9s12x512dp processor with CW 4.5. I am running in large model mode and using Processor Expert to provide the SetWord function. I have one application that the function works and a very similar application where I fail to update the EEprom. In the failure case in the WriteWord function after the write to EEprom, it does a read to make sure that the write happened (shown in red in the following code). the contents of the EEprom remain at 0xFFFF and the function returns an error.
static byte WriteWord(stateMem_TAddress AddrRow,word Data16)
{
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 */
*(AddrRow) = Data16; /* Array address and program data */
/* ECMD: ??=0,CMDB=32 */
ECMD = 32; /* Word program 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 & 0xC0) != 0xC0) {} /* Wait for command completition */
if (*(AddrRow) != Data16) { /* Was attempt to write data to the given address errorneous? */
return ERR_VALUE; /* If yes then error */
}
return ERR_OK; /* OK */
}
What should I look for in differences to see why the one application fails?