AN2183 Freescale Semiconductor / Motorola, AN2183 Datasheet - Page 27

no-image

AN2183

Manufacturer Part Number
AN2183
Description
Using FLASH as EEPROM on the MC68HC908GP32
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
;
;
EEWrite1:
;
;
;
EEWrite2:
;
;
;
;
;
;
;
;*
;*
;*
;*
;*
;*
AN2183
MOTOROLA
If there’s no room, then erase entire FlashEE page.
Copy FlashEE byte program routine into RAM
Prepare source and destination pointers and FlashEE block byte counter.
Execute program routine in RAM.
RAM Executable FlashEE Block Program Subroutine
This subroutine controls the FlashEE block programming sequence.
This subroutine is copied into and executed from RAM.
to be called via "jsr ,x".
ldx
lda
psha
pulh
bsr
pshx
pshh
ldhx
lda
psha
dbnzx
tsx
lda
sta
lda
sta
lda
sta
sta
lda
sta
sta
tpa
sei
jsr
ais
tap
rts
7,sp
6,sp
EEErase
#RamWriteSize
RamWriteEE-1,x
EEWrite2
{RamWriteSize+2},x
{RamWriteSRC},x
{RamWriteSize+3},x
{RamWriteSRC+1},x
{RamWriteSize},x
{RamWriteDST1},x
{RamWriteDST2},x
{RamWriteSize+1},x
{RamWriteDST1+1},x
{RamWriteDST2+1},x
,x
#{RamWriteSize+5}
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
; get first FlashEE row address lsb
; get first FlashEE
;
;
; erase entire FlashEE page
; save block
;
; initialize program size counter
; get program from Flash
; copy onto stack
; decrement pointer and loop back until done
; use H:X to point to RAM executable routine
; get source address msb
; save it in RAM executable routine
; get source address lsb
; save it in RAM executable routine
; get destination address msb
; save it in
;
; get destination address lsb
; save it in
;
; get CCR for current I-bit status
; disable all interrupts
; write data into Flash
; deallocate stack space used
; restore previous CCR, specifically the I-bit
; return
row address
destination pointer
RAM executable routine
RAM executable routine
msb
========================================
It is self-modifying and expects
Application Note
flashee.asm
27

Related parts for AN2183