AN2690 Freescale Semiconductor / Motorola, AN2690 Datasheet - Page 31

no-image

AN2690

Manufacturer Part Number
AN2690
Description
Low Frequency EEPROM Emulation on the MC68HLC908QY4
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
;*******************************************************************************************
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*******************************************************************************************
WrtBlock:
blkfnd:
;*******************************************************************************************
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
;*
MOTOROLA
rts
WrtBlock - Writes a block of data into FLASH from RAM buffer
Calling convention:
Inputs:
Returns: nothing
Uses:
mov
clr
psha
bsr
cmp
beq
jsr
txa
and
tax
pula
pshx
add
deca
tax
sthx
pulx
jmp
FindClear - Finds first erased block within page
Inputs:
Returns if erased block found:
Returns if no erased block found (page full):
#13,CPUSpd
CtrlByt
FindClear
#$FF
blkfnd
EraRnge
#$C0
1,sp
LstAddr
PgrRnge
H:X - pointing to start of FLASH page used for data
A
FindClear, EraRnge (ROM), PgrRnge (ROM)
H:X - pointing to start of page used for required data
Stack - block size last thing on stack
H:X - pointing to start of first erased block in page
A
H:X - pointing to start of last written block
A
- block size
- $FF
- $00
Low Frequency EEPROM Emulation on the MC68HLC908QY4
Freescale Semiconductor, Inc.
ldhx
lda
jsr
For More Information On This Product,
#Blk1page
#Blk1Size
WrtBlock
Go to: www.freescale.com
;3.2MHz/0.25MHz = 13
;page (not mass) erase
;save block size
;find first available erased block
;erased block found ?
;if so write to it
;if not then erase page
;get LS byte of FLASH address
;and reset it to start of page
;H:X now pointing to first block
;get block size
;save start address LS byte
;add block size to LS byte
;back to last address in block
;last address now in H:X
;save in RAM for use by ROM routine
;restore X (H hasn't changed)
;program block (includes RTS)
Appendix A: Sample Application
AN2690
31

Related parts for AN2690