AN2400 Freescale Semiconductor / Motorola, AN2400 Datasheet - Page 40

no-image

AN2400

Manufacturer Part Number
AN2400
Description
HCS12 NVM Guidelines
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2400/D
EEPROM Sector
Modify Command
40
ESTAT.byte = ACCERR|PVIOL;
if(ESTAT.bit.cbeif == 1)
{
}
else
{
}
if((ESTAT.byte & (ACCERR|PVIOL))!= 0)
*eepromAddr = dummy;
ECMD.byte = ERASE_VERIFY;
ESTAT.byte = CBEIF;
{
}
while(ESTAT.bit.ccif != 1)
{
}
if(ESTAT.bit.BLANK == 1)
{
}
else
{
}
return(FAIL);
return(FAIL);
return(PASS);
return(FAIL)
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 and the
EEPROM verified as erased, or 1 if the command failed or the EEPROM was
not erased.
The following code segment demonstrates how to reprogram a sector (4 bytes)
of EEPROM using the sector modify command followed by a pipelined program
command.
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, the sector to be
programmed must not 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
Go to: www.freescale.com
MOVB
BRCLR $115,#$80,eeevf Check command buffer is empty
STD
MOVB
MOVB
BRSET $115,#$30,eeevf Command failed if either error flag set
BRCLR $115,#$40,*+0
BRCLR $115,#$04,eeevf Check BLANK bit
CLRB
BRA
eeevf:
LDAB
eeevrtn:
RTS
HCS12 NVM Guidelines
return address.
eeevrtn
#$30,$115
0,X
#$05,$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: the BLANK flag
is not valid until CCIF is set.
Successful, return
Fail, return
Appendix A ‘C’
MOTOROLA

Related parts for AN2400