AN1827 Freescale Semiconductor / Motorola, AN1827 Datasheet - Page 44

no-image

AN1827

Manufacturer Part Number
AN1827
Description
Programming and Erasing FLASH Memory on the MC68HC908AS60
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Application Note
Erase990:
************************************************************************************
*****
************************************************************************************
* This routine programs the 8 bytes of data from the RAM data buffer to
* the FLASH memory starting at FLASH_addr. The programming is done in
* ascending order, ie. data[0] -> FLASH_addr[0], data[1] -> FLASH_addr[1],
* etc.
*
* The routine is structured into a loop for smart programming so that the
* minimum amount of high voltage is applied to the FLASH. Each time
* through the loop is called a "pulse." Each pulse consists of all 17
* steps shown in the application note, with the programming time, tSTEP,
* equal to approximately 1 ms.
*
* If all 8 bytes program correctly in the approximately 1 ms time period,
* then the routine exits and returns control to the calling program. If
* the 8 bytes do not program correctly, another attempt(pulse) is made.
* This continues for the maximum number of pulses (flsPULSES). If the 8
* bytes are not programmed successfully after a maximum number of pulses,
* then the programming error flag is incremented, the routine is exited
* and the error value (any non-zero value) is returned in the accumulator.
*
*
*
*
*
*
************************************************************************************
Prog8Bytes:
NextAttempt:
44
Initializations required:
Values returned:
lda
jsr
lda
jsr
cli
rts
Set charge pump clock in FLCR1 and FLCR2; FLASH_addr set; data
buffer filled
A = Program Success/Error Flag
sei
clr
ldhx
lda
jsr
Program/Margin Read 8 Bytes of FLASH Memory Subroutine
#erase.
WriteFLCR
#thvd
DELAY
attempt
FLASH_addr
#pgm.
WriteFLCR
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
;Step 8 - Clear the ERASE bit
;Step 9 - Wait for time tHVD
;Enable interrupts
;No interrupts allowed during
; programming
;Step 1 - Clear attempt counter
;Load the address of the page to be
; programmed in the HX register
;Step 2 - Set the PGM bit
MOTOROLA
AN1827
*****
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

Related parts for AN1827