AN2400 Freescale Semiconductor / Motorola, AN2400 Datasheet - Page 31

no-image

AN2400

Manufacturer Part Number
AN2400
Description
HCS12 NVM Guidelines
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
MOTOROLA
FSTAT.byte = ACCERR|PVIOL;
if(FSTAT.bit.cbeif == 1)
{
}
else
{
}
if((FSTAT.byte & (ACCERR|PVIOL))!= 0)
*flashAddr = dummy;
FCMD.byte = ERASE;
FSTAT.byte = CBEIF;
{
}
while(FSTAT.bit.ccif != 1)
{
}
if(FSTAT.bit.BLANK == 1)
{
}
else
{
}
return(FAIL);
return(FAIL);
return(PASS);
return(FAIL)
assuming the register base address is $0000, and the rightmost column
contains comments.
Prerequisites: FCLKDIV must be configured correctly, the Flash address must
be word aligned (bit 0 = 0). If the Flash address is in the range $8000 to $BFFF,
the PPAGE register must be written to select any page in the Flash block. If the
microcontroller has multiple Flash blocks, the ACCERR and PVIOL flags in all
other blocks must be clear and the BKSEL bits in the FCNFG register must be
written to select the desired block for erase verify.
Registers: X contains word aligned Flash address within the Flash block to be
verified.
Stack Pointer
C function local variables: UINT16* flashAddr, UINT16 dummy.
On return, accumulator B contains 0 if the command executed correctly and the
Flash block verified as erased, or 1 if the command failed or the Flash block did
not verify as erased.
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MOVB
BRCLR $105,#$80,feevf Check command buffer is empty
STD
MOVB
MOVB
BRSET $105,#$30,feevf Command failed if either error flag set
BRCLR $105,#$40,*+0
BRCLR $105,#$04,feevf Check BLANK bit
CLRB
BRA
feevf:
LDAB
feevrtn:
RTS
HCS12 NVM Guidelines
return address.
feevrtn
#$30,$105
0,X
#$05,$106
#$80,$105
#1
Clear error flags on selected block
Write any data to Flash sector address
Write erase verify command
Write '1' to CBEIF to launch the command
Wait for command to finish: the BLANK bit
is not valid until CCIF is set.
Successful, return
Fail, return
Flash Memory
AN2400/D
31

Related parts for AN2400