AN2183 Freescale Semiconductor / Motorola, AN2183 Datasheet - Page 25

no-image

AN2183

Manufacturer Part Number
AN2183
Description
Using FLASH as EEPROM on the MC68HC908GP32
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
EEErase1:
;
;
;
;
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
EEFindFirst:
EEFindFirst1:
AN2183
MOTOROLA
Execute program routine in RAM.
Find First Erased FlashEE Location Subroutine
This subroutine is used to find the first erased FlashEE block, starting at the
address being pointed to by H:X.
Calling convention:
Returns:
Changes:
lda
psha
dbnzx
tsx
tpa
sei
jsr
ais
pulh
pulx
tap
rts
ldhx
lda
jsr
psha
lda
psha
lda
cmp
beq
pula
sub
bmi
psha
txa
add
tax
pshh
pula
adc
psha
pulh
bra
RamEraseEE-1,x
EEErase1
,x
#RamEraseSize
#address
#EE_BlockSize
EEFindFirst
H:X ->
ACC
CCRZ =
everything
#EE_FlashRow
#EE_FlashErased
,x
EEFindFirst2
1,sp
EEFindFirst3
2,sp
#0
EEFindFirst1
=
first erased FlashEE block address
number of erased FlashEE bytes left
set if erased location successfully found, otherwise clear
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
The FlashEE data block size is passed forward in ACC.
; get program from Flash
; copy into Stack
; decrement pointer and loop back until done
; use H:X to point to RAM executable routine
; get CCR
; disable all interrupts
; erase Flash page
; deallocate stack space used
; restore
;
; restore previous CCR
; return
; save FlashEE data block size
; get Flash Program Row size
; save on stack as a counter
; get erased Flash data
; check if Flash location is erased
; exit if so
; else, get counter
; adjust by subtracting block size
; exit if out of room
; else, save new count
; perform
;
;
;
;
;
;
;
; loop back
address pointer
16-bit addition
in order
to advance
FlashEE pointer
==========================================
forwards
to the
next block
Application Note
flashee.asm
25

Related parts for AN2183