AN2183 Freescale Semiconductor / Motorola, AN2183 Datasheet - Page 24
AN2183
Manufacturer Part Number
AN2183
Description
Using FLASH as EEPROM on the MC68HC908GP32
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
1.AN2183.pdf
(48 pages)
Application Note
;
;
;
;
;
;
;
RamEraseEE1:
;
;
;
;
RamEraseSize:
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
EEErase:
;
;
;
24
Step 2:
Wait for >10us, then set HVEN.
Step 3:
Wait for >1ms, then clear ERASE.
Step 4:
Wait for >5us, then clear HVEN, then wait >1us and return.
FlashEE Page Erase Subroutine
This subroutine will erase the Flash memory page that is being pointed to by H:X.
60 bytes of stack space is used, including this subroutine’s call return address.
Calling convention:
Returns:
Changes:
Copy FlashEE page erase routine into RAM
lda
dbnza
lda
sta
ldx
lda
dbnza
dbnzx
lda
sta
lda
dbnza
clra
sta
pula
brn
rts
ldhx
jsr
pshx
pshh
ldhx
#RamDelay10
*
#{ERASE | HVEN}
flcr
#20
#RamDelay50
*
RamEraseEE1
#{HVEN}
flcr
#RamDelay5
*
flcr
*
equ
#EE_StartAddr
EEErase
H:X unchanged
ACC
#RamEraseSize
{*-RamEraseEE}
Freescale Semiconductor, Inc.
For More Information On This Product,
==========================================================
Go to: www.freescale.com
; wait
;
; set HVEN control bit
;
; outer loop
;
; inner loop
;
; loop back until done
; clear ERASE control bits
;
; wait
;
; clear HVEN control bit
;
; retreive previous CCR
; wait for at least 1us before
;
; save pointer
;
; initialize pointer
for 10us
in Flash Control Register
set for 20x
set for 50us
in Flash Control Register
for 5us
in Flash Control Register
on stack
returning
MOTOROLA
AN2183