Advertisement
Articles
Advertisement

Benefits of Flash EEPROM: Re-programming the End Application Becomes Easy

Tue, 09/25/2007 - 12:42pm
Roger Fan, Freescale Semiconductor, Inc.

When compared to one time programmable (OTP) or read only memory (ROM) microcontrollers (MCUs), a flash memory-based MCU is distinguished by its ability to be reprogrammed. Many applications today need memory not only for storing the application program but also for storing data, which may need to be updated from time to time and must be retained in the application system, even after power off. For example, with a remote control, the user does not want to lose the preferred settings every time the battery is changed. External serial EEPROM can serve this purpose well, but adding another component to the system means higher system cost, a larger board footprint and degraded system reliability. An MCU with reprogrammable flash memory is a good choice for such an application, particularly if the application program needs a periodic upgrade to a newer version with enhanced features.

To best utilize flash memory for electrically erasable programmable read only memory (EEPROM) emulation or firmware upgrades, the MCU must be designed with a good flash controller module. This allows the embedded designer to in-system program or erase the flash memory in a comparatively convenient and user-friendly way. A special flash control module can also be used so that developers do not need to manipulate the bits of the flash control registers. Instead, firmware developers just need to issue erase or programming commands from the application program. When programming or erasing the flash memory, an internal charge pump eliminates the need for external high voltage.
 
In this article, we describe the flash EEPROM features of a flash-based MCU and how end applications can benefit from specially designed dual flash arrays.


Emulating EEPROM Using a Single Flash Array

Emulating EEPROM using flash memory requires in-system erasing and programming. For devices with a single flash array, the program algorithm used to conduct the programming or erasing operations cannot be located in the same flash array that is going to be programmed or erased. Instead, the algorithm is typically executed from RAM. The user application needs to copy the program algorithm from flash memory to RAM and then jump to this RAM program to execute the algorithm. 

An alternative strategy, to avoid having to copy the program algorithm from RAM, is to hard code the program in the MCU’s ROM during wafer processing, allowing the application program to be executed directly from ROM. Figure 1 shows the execution flow of in-system flash programming.

 
Figure 1. In-system programming of single flash array.

Emulating EEPROM Using Dual Flash Arrays

Freescale’s MC9S08LC family of MCUs will be used as an example. Each member has a dual flash array, each with its own flash control logic. The program and erase operations can be performed on one array while executing code from the other. There is no need to execute the program algorithm in RAM or ROM during the in-system programming process. Dual flash arrays greatly simplify the process of using flash to emulate EEPROM. For example, the programming algorithm and the application code can be stored in Flash A while Flash B is treated as flash EEPROM. The user can simply execute the code in Flash A to erase or program data in Flash B.

Benefits to the End Application Using an MCU with Dual Flash Array

 
 
Figure 2. Memory maps of MC9S08LC60/36
True in-system programming. Although it is possible to upgrade the application firmware in a single flash array MCU by uploading the programming and firmware upgrading algorithm to RAM for execution, this involves some risk. If, after the flash array has been erased, there is a power loss during the upgrade process, the random access memory (RAM) content will be lost or corrupted. To bring the end application back to life, the user will need to reprogram the MCU firmware with external tools. This problem can be avoided using an MCU with dual flash arrays. Since the user can execute the algorithm in Flash A to erase and program the application firmware in Flash B and vice versa, a power failure will not disable the upgrade process. In-system programming can simply be restarted from the non-volatile flash memory once power is back on. Using dual flash arrays, true in-system programming can be achieved, giving the product manufacturer complete and reliable remote firmware upgrade capability. 

Simplicity of the system design. Dual flash array in-system programming and EEPROM emulation frees up more RAM for the application and eliminates the need for external EEPROM. It simplifies the application program, which is especially helpful to software engineers who face tight memory resources. In addition, the I/O pins that would have been used for external EEPROM can be used for other functions in the end application.

System cost saving. Total system cost can be reduced by using a smaller pin count MCU with less I/O while still eliminating the need for an external EEPROM component. No system features are sacrificed, yet the PCB is smaller and the testing time on the production line is lowered because the overall system is simpler.

Better system reliability. The most frustrating issue when using a single array flash MCU to perform in-system programming occurs when the power suddenly goes off during the process. By using an MCU with dual flash array, the process is much safer because the programming algorithm in either of the flash arrays will not be lost during power off. This greatly contributes to overall system reliability when undergoing in-system programming activity.

Further advantages can be realized through dual flash array in-system programming. Again using the MC9S08LC family as an example, programming and erasing of each flash array can be conducted through the same command interface, simplifying the end application program. For better system reliability, the flash array is designed so that it is not possible to page-erase or program both arrays at the same time. Since the mass-erase command will erase both arrays, its use is not recommended when coding the end application program. Developers are advised to use page erase command to erase the flash array during in-system programming.

Conclusion

Initially, flash memory was primarily intended for program storage. However, because it can be reprogrammed, it can also be used to emulate EEPROM. MCUs with dual flash arrays provide simpler and more reliable in-system programming to implement EEPROM emulation. Furthermore, sudden power off will no longer disrupt the process in systems employing dual flash array MCUs. Therefore, in-system programming and field upgrades are both easier and safer.

Roger Fan is a System and Application Engineer at Freescale Semiconductor, Inc. For more information, contact Freescale Semiconductor, 6501 William Cannon Drive West, Austin, TX 78735; 800-521-6274; www.freescale.com

 

 

Advertisement

Share this Story

X
You may login with either your assigned username or your e-mail address.
The password field is case sensitive.
Loading