MC9s12D64 Write EEPROM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MC9s12D64 Write EEPROM

1,472件の閲覧回数
topchair
Contributor I
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);  }        }

 

ラベル(1)
0 件の賞賛
返信
1 返信

621件の閲覧回数
kef
Specialist I


topchair wrote:

With the help of my debugger (NoICE12), I find that ESTAT register never change.


Eeprom programming is to quick to notice it with debugger. Erase takes ~20ms, program ~0.1ms. It's very likely that it takes more than 20ms from breakpoint is hit to when debugger notices that and reads from ESTAT. Try sampling ESTAT to some variable, then read it with debugger. 

0 件の賞賛
返信