AN2400 Freescale Semiconductor / Motorola, AN2400 Datasheet - Page 39

no-image

AN2400

Manufacturer Part Number
AN2400
Description
HCS12 NVM Guidelines
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
EEPROM Mass Erase
Command
EEPROM Erase
Verify Command
MOTOROLA
ESTAT.byte = ACCERR|PVIOL;
if(ESTAT.bit.cbeif == 1)
{
}
else
{
}
if((ESTAT.byte & (ACCERR|PVIOL))!= 0)
*eepromAddr = dummy;
ECMD.byte = MASS_ERASE;
ESTAT.byte = CBEIF;
{
}
while(ESTAT.bit.ccif != 1)
{
}
return(PASS);
return(FAIL);
return(FAIL);
The following code segment demonstrates how to erase the entire EEPROM.
The leftmost column contains C code (variable definitions in
Variable
assuming the register base address is $0000, and the rightmost column
contains comments.
Prerequisites: ECLKDIV must be configured correctly, no part of EEPROM
must be protected, the EEPROM address must be word aligned (bit 0 = 0).
Registers: X contains any word aligned EEPROM address.
Stack Pointer
C function local variables: UINT16* eepromAddr, UINT16 dummy.
On return, accumulator B contains 0 if the command executed correctly, or 1 if
the command failed.
The following code segment demonstrates how to verify whether the entire
EEPROM is erased.
The leftmost column contains C code (variable definitions in
Variable
assuming the register base address is $0000, and the rightmost column
contains comments.
Prerequisites: ECLKDIV must be configured correctly, no part of EEPROM
must be protected, the EEPROM address must be word aligned (bit 0 = 0).
Freescale Semiconductor, Inc.
For More Information On This Product,
Definitions), the centre column contains equivalent assembly code
Definitions), the centre column contains equivalent assembly code
MOVB
BRCLR $115,#$80,eemef Check command buffer is empty
STD
MOVB
MOVB
BRSET $115,#$30,eemef Command failed if either error flag set
BRCLR $115,#$40,*+0
CLRB
BRA
eemef:
LDAB
eemertn:
RTS
Go to: www.freescale.com
HCS12 NVM Guidelines
return address.
eemertn
#$30,$115
0,X
#$41,$116
#$80,$115
#1
Clear error flags
Write any data to EEPROM address
Write mass erase command
Write '1' to CBEIF to launch the command
Wait for command to finish: this is
optional, but the EEPROM cannot be accessed
until CCIF is set.
Successful, return
Fail, return
Appendix A ‘C’
Appendix A ‘C’
AN2400/D
EEPROM
39

Related parts for AN2400