AN2183 Freescale Semiconductor / Motorola, AN2183 Datasheet - Page 23

no-image

AN2183

Manufacturer Part Number
AN2183
Description
Using FLASH as EEPROM on the MC68HC908GP32
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
;
;
;
EERead1:
EERead2:
EERead3:
;*
;*
;*
;*
;*
;*
RamEraseEE:
;
;
;
;
;
;
;
;
AN2183
MOTOROLA
If the second row is erased, then return pointing to the last block in the first row.
Otherwise, return pointing to the last used block in the second row.
RAM Executable FlashEE Page Erase Subroutine
This subroutine will erase the Flash memory page that is being pointed to by H:X.
This subroutine is copied into and executed from RAM and expects to be called via
"jsr ,x".
Retrieve page address.
Step 1:
Set ERASE, read the Flash Block Protect Register and write any data into Flash page.
txa
pulx
aix
psha
lda
cmp
bne
pulx
pshx
bra
lda
bsr
txa
sub
tax
pshh
pula
sbc
psha
pulh
ais
lda
rts
psha
lda
ldx
psha
pulh
lda
sta
lda
sta
#EE_FlashRow
,x
#EE_FlashErased
EERead1
EERead2
2,sp
EEFindFirst
2,sp
#0
#2
,x
{RamEraseSize},x
{RamEraseSize+1},x
#{ERASE}
flcr
flbpr
,x
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
; save current address lsb
; restore FlashEE address lsb
; H:X now points to second program row
; save previous address lsb on stack
; check if first location
;
; skip if so
; else, restore previous FlashEE address lsb
; put back on stack for clean exit
; and exit
; get FlashEE data block size
; go find next free location
; perform
;
;
;
;
;
;
;
; deallocate stack usage
; get first FlashEE data byte
; return
; save previous CCR on stack
; get msb
;
; put msb
;
; set ERASE control bit
;
; read from Flash Block Protect Register
; write any data to address within page
is erased
16-bit subtraction
and lsb of address
into HREG
in Flash Control Register
in order
to adjust
FlashEE pointer
===========================================
backwards
one data block
size
Application Note
flashee.asm
23

Related parts for AN2183