AN1827 Freescale Semiconductor / Motorola, AN1827 Datasheet - Page 57

no-image

AN1827

Manufacturer Part Number
AN1827
Description
Programming and Erasing FLASH Memory on the MC68HC908AS60
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Erase990:
}
/**********************************************************************************/
/****
/**********************************************************************************/
/* This routine programs the 8 bytes of data from the RAM data array 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 1ms 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.
/*
AN1827
MOTOROLA
DisableInterrupts;
writeFLCR (ERASE);
Blk_Protect1 = FLBPR1;
Blk_Protect2 = FLBPR2;
*FLASH_addr = 0xFF;
writeFLCR (HVEN);
for (loop=0x15; loop !=0; loop--)
writeFLCR (HVEN);
Delay (tKILL);
writeFLCR (ERASE);
Delay (tHVD);
EnableInterrupts;
return;
Delay (tERASE);
Program/Margin Read 8 Bytes of FLASH Memory Subroutine
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
/* Enable Interrupts
/* Disable interrupts
/* Step 1 - Set the ERASE bit
/* Step 2 - Read from the block
/*
/* Step 3 - Write to any FLASH
/*
/*
/* Step 4 - Set the HVEN bit
/* Step 5 - Wait for time tERASE
/* Step 6 - Clear the HVEN bit
/* Step 7 - Wait for time tKILL
/* Step 8 - Clear the ERASE bit
/* Step 9 - Wait for time tHVD
protect registers
address within the block address */
range with any data value
Application Note
C Source Code
*****/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
57

Related parts for AN1827