© Motorola, Inc ., 20 03
MOTOROLA.COM/SEMICONDUCTORS
Motorola 56F8300
Hybrid Controller
Family
56F83xx Lends
Hybrid
Applications
EEPROM
Capability
FlashEE
White Paper
Rev. 0, 9/03
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
© Motorola, Inc ., 20 03
56F83xx Lends Hybrid
Applications EEPROM
Capability -- FlashEE
John L. Winters
1. Introduction
1.1 Overvi ew
Motorola has introduced a new class of hybrid MCU/DSP
devices addressing the needs associated with automotive,
industrial, consumer, motor control and other system control
applications requiring Flash memory and EEPROM
capability. These devices are the 56F8322, 56F8323,
56F8345, 56F8346, 56F8356, and 56F8357 parts,
collectively referred to as the 56F 83xx family .
This report presents the architectural advantage offered by
the 56F83xx family of devices with respect to using its
on-chip Flash as EEPROM. It also recounts the method used
to demonst rate this capa bility a nd d ispla ys some of the so urce
code.
Why use on-chip Flash as EEPROM?
A control system may be required to store a variety of
information, including control information, calibration data,
phone numbers, data logs, temperature exteme data,
maximum velocity data, boundry GPS coordinates, and many
other types of data. This data may need to be updated by the
control system autonomously, perhaps in the field of
deployment, and may be required for the system’s self-
calibration. The information stored may need to be retained,
even when power is not supplied to the device. In many
applications, an EEPROM is required to store non-volatile
data; it could be eliminated if the 56F83xx’s on-board Flash
could be used to store all of this data. Using Flash to replace
EEPROM has been named “FlashEE in a previous Motorola
Application Note (please see Reference 1).
Contents
Introduction ........................................1
1.1 Overview.........................................1
1.2 The Keys to FlashEE.......................2
1.3 How the Keys Open the Way..........2
Using the Keys -- Flash EE on a 56F3xx
Device....................................... 2
2.1 A Program Illustrates the Concept..2
2.2 The Program Explained ..................4
Conclusion .........................................8
References ..........................................8
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
2Best of DSP and MCU Worlds Motorola
Using the Keys -- FlashEE on a 56F3xx Device
1.2 The Ke ys to Fl ashEE
The keys to unlock FlashEE reside within the Flash memory subsystem of the 56F83xx family:
A minimum of up to 10K write/erase cycles across temperature range; up to 100K is typical
A data Flash Memory Page size of only 256 words
No special voltages are required for Flash programming
1.3 How th e Keys O pen the Way
The Motorola 56F83xx family includes all three keys. But wha t if jus t one of these keys is omitted?
Omit the first key and it will wear out the Flash before the normal life cycle of the product
Omit the second key and the number of data words used up each time any parameter must be
updated will soon cy cle th rough all ava ilable memor y, result ing in a li near decr ease of pr oduct
life
For example, if the page size was 8K and only 256 words needed to be written at once, then
most of the 8K words would be wasted and the product life would decrease by a factor of 16,
assuming equal memory si zes.
Omit the last key and special voltages would be needed just to update data in FlashEE
Theres no need to do without any of these keys, since they are all built into the Flash Memory
subsystem of the Motorola 56F83xx family of devices.
2. Using the Keys -- FlashEE on a 56F3xx Device
2.1 A Progr am Illu strates t he Conc ept
The tested, working C program at the end of this section has been used to train engineers using
FlashEE on a 56F83xx controller. Section 2.2 discusses the operation of this program in detail.
By writing such a simple program, its easy to use as a seed for m ore complex applications requiring
FlashEE. It can be cut/pasted into an application, tested, then scaled up to the data structure to be
saved. Integration would then meld the FlashEE technique into the application. This is a stand-alone
example which uses simple subroutines.
This simple example just writes one 16-bit word to the Data FLASH using the FlashEE technique.
When a page final ly fi lls up , it i s no t used a gain un til i t is erase d. This e xample t hen shows how to sa ve
the value of a 16-bit word in a non-volatile manner using the FlashEE technique.
Why FlashEE 16 bits and not just one bit at a time? Since both the row size and the word size are 16
bits, each word may be written only once prior to erasing. Thus, if only one bit is be stored, it would
have to be stored in a 16-bit word. Repeated writes to a word without an erase can damage the Flash,
sinc e the specif ications would be exceeded.
Code Example 1 is a part of a larger program, which is available with all source code, including
subroutines. See Reference 3.
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
Using the Keys -- FlashEE on a 56F3xx Device
MOTOROLA Best of DSP and MCU Worlds 3
Code Example 1.
/* Using Flash as EEPROM on 56F 836 -- Training Modul e */
#include "ssd_t ypes.h"
#include "ssd_h fm.h"
#include "ssd_h fm_config.h"
#include "ssd_d emo.h"
#include "ssd_h fm_clk.h"
#include "clock .h"
#include <stdio .h>
#include <stdli b.h>
// Flash config uration stucture
FlashConfig fla shConfig =
{
HFM_BASE,
HFM_CONFIG_BAS E,
FLASH_CLOCK_DI VIDER,
false
};
UWord16 buffer[ SOURCE_DATA_BUFF ER_SIZE];
UWord16 main(vo id)
{
UWord16 Flash _bits; // as read from fla sh
UWord16 i; // Index
FLASH_TYPE fla shType; // The type of flas h block
UWord32 flash BaseAddr, // Th e base address of fla sh block
flash Size; // The size of flas h block
UWord32 erase BlkStartAddr; // The start addres s of flash block
UWord16 numbe r; // Flash page numbe r operation applicabl e
UWord32 sourc e; // Source address f or program and verify
UWord32 dest, // Flash start addr ess operation applica ble
size; // Flash size opera tion applicable
UWord32 Flash _p ; // Pointer to flash
// Set the vec tor base address
REG_WRITE(INTC _BASE_ADDRESS + INTC_VBA, 0x300);
// Set the PLL
SetPLL(PLL_PRE SCALER, PLL_POST SCALER, PLL_MULTIPLIE R);
//============ =============== Initialize HFM Module for Data Flash
===========================
FlashInit((UWo rd32)(&flashConf ig));
flashType = FL ASH_TYPE_D;
flashBaseAddr = DATA_FLASH_STA RT_ADDR;
flashSize = DA TA_FLASH_SIZE;
number = DATA_ FLASH_SIZE / FLA SH_PAGE_SIZE_D;
// Clear the a ll protect bits
FlashSetProtec tion((UWord32)(& flashConfig), flashTy pe, 0x0000);
//============ =============== Find unused flash wor d (=1)
===========================
for (Flash_p = DATA_FLASH_STA RT_ADDR;
Flash_p < DATA_FLASH_STAR T_ADDR + DATA_FLASH_S IZE;
Flash_p + +
) // if word is 0xfff it must be errased alre ady:
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
4Best of DSP and MCU Worlds Motorola
Using the Keys -- FlashEE on a 56F3xx Device
if (*(UWo rd16*)Flash_p == 0xffff) break; // se arch for an unused wo rd.
if (Flash_p == DATA_FLASH_START_ADDR + DATA_FLASH_SIZE) // if flash used up, mass
erase.
{
//======= ================ ===== Mass Erase Flas h (if all bits zero)
===============================
eraseBlkS tartAddr = flash BaseAddr;
FlashMassErase((UWo rd32)(&flashConfig), flashType, eraseBlkStartAdd r);
Flash_p = DATA_FLASH_STAR T_ADDR; // flash now empty again!
}
// Flash_p now points to f irst flash location w ith unused word.. wh ich must
exist.
Flash_bits = 0x1234 ; // change to any value other t han 0xffff
//======== ================ ====== Program the on e word into the Flash
================================
source =(U Word32) &Flash_b its; // source f or write to flash
dest = Fla sh_p; // destinat ion for write to flas
size = 1; // number o f 16 bit words to wri te to flash
FlashProgr am((UWord32)(&fl ashConfig), flashType , dest, size, source) ;
printf ("\ n *Flash_p= %x \ n", *(UWord16*)Flash_ p); // show word i n flash
printf ("\n Flash_p= %x \n",(UWord16)Flash_p); // show flash address
// Solution
if ( Fl ash_p & 1 // each time program runs, it writes another wo rd.
// After one run, the program prin ts odd
// After two, even. The pattern c ontinues.
// Power fail ures do not affect it .
// After all words are used, they are all cleared and t he
// pattern co ntinues. Since erasu re is infrequent, the life
// of the mem ory is long.
)
printf (" \n\n Odd");
else prin tf ("\n\n Even") ;
}
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
Using the Keys -- FlashEE on a 56F3xx Device
MOTOROLA Best of DSP and MCU Worlds 5
2.2 The Program Ex plained
Code Example 2 brings in both the header files for low-level Flash subroutines that access the Flash,
and standard header files so that the debugger can output messages.
Code Example 2.
/* Using Flash as EEPROM on 56F 836 -- Training Modul e */
#include "ssd_t ypes.h"
#include "ssd_h fm.h"
#include "ssd_h fm_config.h"
#include "ssd_d emo.h"
#include "ssd_h fm_clk.h"
#include "clock .h"
#include <stdio .h>
#include <stdli b.h>
The FLASH configuration structure in Code Example 3 configures the Flash for operation.
Code Example 3.
----------
// Flash config uration stucture
FlashConfig fla shConfig =
{
HFM_BASE,
HFM_CONFIG_BAS E,
FLASH_CLOCK_DI VIDER,
false
};
UWord16 buffer[ SOURCE_DATA_BUFF ER_SIZE];
Code Example 4 includes the start of the actual code for the main program, the first
application-oriented item to gain control of the processor.
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
6Best of DSP and MCU Worlds Motorola
Using the Keys -- FlashEE on a 56F3xx Device
Code Example 4.
----------
UWord16 mai n(void)
{
Code Example 5 displays data illustrating the technique of FlashEE.
Code Example 5.
----------
UWord16 Fl ash_bits; // as read from flash
UWord16 i ; // Index
FLASH_TYPE flashType; // The type of flash block
UWord32 f lashBaseAddr, / / The base address of flash block
f lashSize; // The size of flash block
UWord32 e raseBlkStartAddr ; // The start ad dress of flash block
UWord16 n umber; // Flash page n umber operation appli cable
UWord32 s ource; // Source addre ss for program and ve rify
UWord32 d est, // Flash start address operation app licable
s ize; // Flash size o peration applicable
UWord32 F lash_p ; // Pointer to f lash
Code Example 6 includes initialization code and will vary from application to application. It is the
first code run within this main.c program.
Code Example 6.
----------
// Set the vector base addr ess
REG_WRITE( INTC_BASE_ADDRES S + INTC_VBA, 0x300);
// Set the PLL
SetPLL(PLL _PRESCALER, PLL_ POSTSCALER, PLL_MULTI PLIER);
//======== ================ === Initialize HFM Mo dule for Data Flash
===========================
FlashInit((UWor d32)(&flashConfig));
flashType = FLASH_TYPE_D;
flashBaseA ddr = DATA_FLASH _START_ADDR;
flashSize = DATA_FLASH_SIZ E;
number = D ATA_FLASH_SIZE / FLASH_PAGE_SIZE_D;
// Clear t he all protect b its
FlashSetPr otection((UWord3 2)(&flashConfig), fla shType, 0x0000);
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
Using the Keys -- FlashEE on a 56F3xx Device
MOTOROLA Best of DSP and MCU Worlds 7
Code Example 7 makes use of the row size of 16 bits. It searches for a word equal to 0xffff, or all 16
bits equal to one when viewed as a binary number: 1111111111111111. This is the value the word
takes on when it is erased.
Code Example 7.
----------
//============= ============== F ind unused flash word (=1)
===========================
for (Flash_p = DATA_FLASH_STA RT_ADDR;
Flash_p < DATA_FLASH_STAR T_ADDR + DATA_FLASH_S IZE;
Flash_p + +
) // if word is 0xfff it must be errased alre ady:
if (*(UWord16 *)Flash_p == 0xf fff) break; // search for an unused word.
if (Flash_p == DATA_FLASH_START_ADDR + DATA_FLASH_SIZE) // if flash used up, mass
erase.
{
As shown in Code Example 8, if the code falls through to this point, it means that all Flash is used
and a mass erase will take place.
Code Example 8.
----------
//============= ====== Mass Eras e Flash (if all bits zero) =============== =======
eraseBlkStart Addr = flashBase Addr;
FlashMassEras e((UWord32)(&fla shConfig), flashType, eraseBlkStartAddr);
Flash_p = DAT A_FLASH_START_AD DR; // flash now emp ty again!
}
In Code Example 9, the meani ng of the t oken 0xfff f is erase d, s o we can st or e any othe r number us ing
this technique.
This will keep track of how much memory has been used so that its not necess ary to use even more
memory (and time) to track this data.
Code Example 9.
----------
// Flash_p now points to first flash location with unused word.. which must exist.
Flash_bits = 0 x1234 ; // change to any value other than 0xffff
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
8Best of DSP and MCU Worlds Motorola
Conclusion
The simple toggle function calculates odd or even numbers of program runs; each run uses one word.
See Code Example 10.
Code Example 10.
----------
//========= ================ ===== Program the one word into the Flash
================================
source =(U Word32) &Flash_b its; // source f or write to flash
dest = Flas h_p; // destinati on for write to flas
size = 1; // number o f 16 bit words to wri te to flash
FlashProgr am((UWord32)(&fl ashConfig), flashType , dest, size, source) ;
printf ("\ n *Flash_p= %x \ n", *(UWord16*)Flash_ p); // show word i n flash
printf ("\n Flash_p= %x \n",(UWord16)Flash_p); // show flash address
// Solution
if ( Fl ash_p & 1 // each time program runs, it writes another wo rd.
// After one run, the program prin ts odd
// After two, even. The pattern c ontinues.
// Power fail ures do not affect it .
// After all words are used, they are all cleared and t he
// pattern co ntinues. Since erasu re is infrequent, the life
// of the mem ory is long.
)
printf (" \n\n Odd");
else prin tf ("\n\n Even") ;
}
3. Conclusion
A real application can store real data in these words. Since only one word is written at a time, and the
Flash is page erasable, making a useful FlashEE application is simple. The specifications of the Flash
make it well-suited for use as EEPROM when the total updates are in the tens to hundreds of
thousands. The design of the Motorola 56F83xx Flash unit makes this practical.
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
References
MOTOROLA Best of DSP and MCU Worlds 9
4. References
1) Using FLASH as EEPROM on the MC68HC908CP32, AN2183/D
2) Motorola 56F83x Hybrid MCU/DSP Flash Family
3) Using FLASH as EEPROM Training Exercise
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...
HOW TO REACH US:
USA/EUROPE/LOCATIONS NOT LISTED:
Motorola Literature Distribution;
P.O. Box 5405, Denver, Colorado 80217
1-303-675-2140 or 1-800-441-2447
JAPAN:
Motorola Japan Ltd.; SPS, Technical Information Center,
3-20-1, Minami-Azabu Minato-ku, Tokyo 106-8573 Japan
81-3-3440-3569
ASIA/PACIFIC:
Motorola Semiconductors H.K. Ltd.;
Silicon Harbour Centre, 2 Dai King Street,
Tai Po Industrial Estate, Tai Po, N.T., Hong Kong
852-26668334
TECHNICAL INFORMATION CENTER:
1-800-521-6274
HOME PAGE:
http://www.motorola.com/semiconductors
Information in this document is provided solely to enable system and software
implementers to use Motorola products. There are no express or implied copyright
licenses granted hereunder to design or fabricate any integrated circuits or
integrated circuits based on the information in this document.
Motorola reserves the right to make changes without further notice to any products
herein. Motorola makes no warranty, representation or guarantee regarding the
suitability of its products for any particular purpose, nor does Motorola assume any
liability arising out of the application or use of any product or circuit, and specifically
disclaims any and all liability, including without limitation consequential or incidental
damages. “Typical” parameters which may be provided in Motorola data sheets
and/or specifications can and do vary in different applications and actual
performance may vary over time. All operating parameters, including “Typicals”
must be validated for each customer application by customer’s technical experts.
Motorola does not convey any license under its patent rights nor the rights of
others. Motorola products are not designed, intended, or authorized for use as
components in systems intended for surgical implant into the body, or other
applications intended to support or sustain life, or for any other application in which
the failure of the Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for any such
unintended or unauthorized application, Buyer shall indemnify and hold Motorola
and its officers, employees, subsidiaries, affiliates, and distributors harmless
against all claims, costs, damages, and expenses, and reasonable attorney fees
arising out of, directly or indirectly , any claim of personal injury or death associated
with such unintended or unauthorized use, even if such claim alleges that Motorola
was negligent regarding the design or manufacture of the part.
Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark
Office. digital dna is a trademark of Motorola, Inc. This product incorporates
SuperFlash® technology licensed from SST. All other product or service names are
the property of their respective owners. Motorola, Inc. is an Equal
Opportun i ty/Affir ma tive Act i on Empl o yer.
© Motorola, Inc. 2003
EEPROMFLASH/D
Freescale Semiconductor, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...