AN2400 Freescale Semiconductor / Motorola, AN2400 Datasheet - Page 41

no-image

AN2400

Manufacturer Part Number
AN2400
Description
HCS12 NVM Guidelines
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
MOTOROLA
ESTAT.byte = ACCERR|PVIOL;
if(ESTAT.bit.cbeif == 1)
{
}
else
{
}
if((ESTAT.byte & (ACCERR|PVIOL))!= 0)
if((ESTAT.byte & (ACCERR|PVIOL))!= 0)
*progAddr = *dataAddr;
ECMD.byte = SECTOR_MODIFY;
ESTAT.byte = CBEIF;
{
}
while(ESTAT.bit.cbeif != 1)
{
}
*(progAddr+1) = *(dataAddr+1);
ECMD.byte = PROG
ESTAT.byte = CBEIF;
{
}
while(ESTAT.bit.ccif != 1)
{
}
return(PASS);
return(FAIL);
return(FAIL);
return(FAIL);
Registers: X contains word aligned EEPROM sector address to be
reprogrammed, Y contains address of first word of data.
Stack Pointer
C function local variables: UINT16* progAddr, UINT16* dataAddr.
On return, accumulator B contains 0 if the commands executed correctly, or 1
if either command failed.
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MOVB
BRCLR $115,#$80,eesmf Check command buffer is empty
LDD
STD
MOVB
MOVB
BRSET $115,#$30,eesmf Command failed if either error flag set
BRCLR $115,#$80,*+0
LDD
STD
MOVB
MOVB
BRSET $115,#$30,eesmf Command failed if either error flag set
BRCLR $115,#$40,*+0
CLRB
BRA
eesmf:
LDAB
eesmrtn:
RTS
HCS12 NVM Guidelines
return address.
eesmrtn
#$30,$115
0,Y
0,X
#$60,$116
#$80,$115
2,Y
2,X
#$20,$116
#$80,$115
#1
Clear error flags
Write first data word to first word of
EEPROM sector
Write sector modify command
Write '1' to CBEIF to launch the command
Wait for buffers to empty
Write second data word to second word of
EEPROM sector
Write program 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
AN2400/D
EEPROM
41

Related parts for AN2400