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.
According to AN2400, after ESTAT = CBEIF , ESTAT must be equal to 0x00.
Any Idea?
Regards
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); } }
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.