can't update EEprom variable

cancel
Showing results for 
Search instead for 
Did you mean: 

can't update EEprom variable

Jump to solution
757 Views
mikey1
Contributor III
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?
Labels (1)
Tags (1)
0 Kudos
1 Solution
91 Views
mikey1
Contributor III
I'm Bad.  I had inadvertenlty commented out the initialization of the the 9s12x register.  Blow this thread

View solution in original post

0 Kudos
1 Reply
92 Views
mikey1
Contributor III
I'm Bad.  I had inadvertenlty commented out the initialization of the the 9s12x register.  Blow this thread

View solution in original post

0 Kudos