Damien Picarougne

MC9s12D64 Write EEPROM

Discussion created by Damien Picarougne on Feb 13, 2009
Latest reply on Feb 13, 2009 by kef
Hi,

I try to save value in my EEPROM. My µ is a MC9S12D64 with oscl 16Mhz.
I use the function progEeprom from AN2204.
After a power down power up, my saved value have changed.

With the help of my debugger (NoICE12), I find that ESTAT register never change.
The value of ESTAT is always 0xC1:smileymad:.

According to AN2400, after ESTAT = CBEIF ,  ESTAT must be equal to 0x00.

Any Idea?

Regards
Code:
UINT8 ProgEeprom(UINT16* progAdr, UINT16* bufferPtr) { if(((UINT16)progAdr & ALIGNED_WORD_MASK) != 0)    // Check for aligned word   {  return(FAIL);  } ESTAT = (ACCERR | PVIOL);// Clear error flags    if( (ESTAT & CBEIF) == CBEIF)// Is command buffer empty–   {  *progAdr++ = *bufferPtr++;// Latch data and address      ECMD = PROG;// Configure prog command   ESTAT = CBEIF;// Launch the command   if(( (ESTAT & ACCERR)  == ACCERR) ||    ((ESTAT & PVIOL) == PVIOL))// Was the access error flag set, violation error flags set ˜       {   return(FAIL);   }  while( (ESTAT & CCIF) != CCIF)// Wait for last command to finish           {   }              return(PASS);  } else  {  return(FAIL);  }        }

 

Outcomes