FLASH Is Not Equal FLASH

Microcontrollers come with different flavors of
integrated program memory, either ROM, OTP (one-time-programmable), or FLASH.
With the later becoming a very popular choice with designers in recent years and
FLASH technology steadily evolving, this article will take a closer look at the
significantly different microcontroller FLASH implementations on the market to
highlight some points you may want to consider when choosing your next FLASH
micro.

The Benefits of FLASH

The benefit any FLASH microcontroller offers
over the older ROM and OTP technologies is quickly summarized in one word:
re-programmability.

Eliminate Scrap: Re-programmability eliminates the scrap of obsolete
material associated with ROM and OTP. It can save you literally thousands of
dollars in the early production ramp-up phase.

Of course, there are much more benefits that FLASH
offers, but whether you can utilize those or not depends on the particular FLASH
implementation on your microcontroller of choice. In the following paragraphs,
I'm going to take a closer look at those different flavors and the additional
benefits they hold.

My Generation?

Since its introduction in the early 90's, FLASH
memory based microcontroller technology has evolved over three distinct
generations, all of which are still on the market today. So in selecting your
FLASH microcontroller, it is important to understand the differences this
evolution has created and the implications it might have for your particular
application.

Generation 1: Out-of-System Programming

First generation FLASH devices use a separate high
voltage supply for programming. Those devices are very much like OTPs in every
aspect, with the added advantage of being re-programmable. The drawback of using
an external high voltage programming supply is that the device needs to be
removed from the circuit for reprogramming. Obviously, to be able to remove the
part, it needs to be socketed, which severely limits your choice of feasible
packages and adds additional cost to your application. If you choose to solder
the part onto the board, you've either got an OTP or you're willing to pay the
re-work cost to disolder the part if necessary.

Generation 2: In-System-Programming

Second generation FLASH microcontrollers feature
in-system programming and single voltage FLASH memory. This technology allows
programming the microcontroller without removing it from the printed circuit
board. However, it requires some additional components on the printed circuit
board and/or operator intervention to program the part. The additional
components are typically used for entering/exiting the FLASH programming mode.

Increased Flexibility, Shorter Time-to-Market

In-System programming brings some additional
benefits into the game. First of all, the parts can be soldered onto the board
and the boards can be completely assembled, tested and put on the shelf even
before software development is complete. It is now possible to program and
re-program the microcontroller anytime, for example at the end-of-line in
production or even just shortly before the board is shipped out. This adds a new
level of flexibility to your production line, parts procurement and warehouse
logistics. This approach also significantly cuts down your time-to-market, as
with both OTP and ROM you typically needed to have the programmed part before
you started assembly of your boards. For ROM in particular it meant a 6...12
weeks time delay between the time you finish your software and the time you got
your ROMed parts delivered.

A short-coming of the in-system approach is that no
remote program memory updates are possible or are only possible with substantial
additional control logic (like another microcontroller). Programming of the
FLASH is only possible within a very narrowly defined voltage and temperature
range. For example, your application might be running at 3V, but programming the
FLASH is only possible at 5V.

Generation 3: Self-Programming FLASH

The latest generation of FLASH microcontrollers
offers all of the other generations' benefits plus some more. It features what
is often referred to as "self-programming" capability, some manufacturers
however also call this "true in-system programming"- so it can be easily
confused with the second generation technology. Self-programming capability is
achieved by adding either a dedicated ROM , FLASH or SRAM boot memory to the
microcontroller. When executing the boot memory code the microcontroller can
receive new code via a serial communication channel (UART, SPI, USB, CAN, etc.)
and program that code into its own FLASH program memory. A separate boot memory
is necessitated by the fact that you can not read (necessary to execute the
FLASH programming code) and write (necessary to program) to the same physical
FLASH memory at the same time. Self-programming usually works over the entire
specified voltage and temperature range of the microcontroller.

Types of Boot Memory:

There are three approaches to implementing boot
memory on microcontrollers: FLASH, ROM and SRAM memory. Of those 3 clearly SRAM
is the most "dangerous" choice for remote upgrades, as the FLASH programming
code has to be loaded from FLASH into SRAM and then the FLASH is being erased.
Imagine what happens if you have a power failure in the middle of updating your
FLASH? Your programming code in the SRAM is gone and your FLASH is already
erased – not recommended for remote updates. This potential hazard of volatile
SRAM is overcome by using either non-volatile FLASH or ROM boot memory. The
advantages of having a FLASH boot block versus ROM is that you can change the
code to implement different communication channels for FLASH programming,
whereas with a ROM boot code you are usually restricted to a single,
manufacturer pre-determined programming interface. ROM offers an added level of
security and reliability as it can not be accidentally erased or corrupted. So
the choice comes down to flexibility versus security and reliability. There are
however, workarounds for the inflexibility of boot ROM. Some manufacturers let
you put your own programming routines into the standard FLASH program memory,
which then jump to the boot memory's write routines to program the FLASH. This
way you can still implement programming via your communication interface of
choice, but it requires greater care when modifying the FLASH memory so you
don't accidentally erase your own programming routines.

Remote Software Updates

With the self-programming capability remote,
in-the-field software updates become possible without adding any external
components or requiring any physical human intervention.

Eliminate External/Embedded EEPROM and Save
Board Space

Another benefit of self-programming is that
applications, which so far used EEPROM to store large data tables that are
rarely modified, can now use the self-programming FLASH memory to store those
tables – saving the cost of external or embedded EEPROM and reducing board
space.

FLASH Endurance: Now another
characteristic of FLASH becomes important: The minimum guaranteed number of
FLASH erase/write cycles. When you're using FLASH to store program information
only, 1000 erase/write cycles is plenty, but if you want to store non-volatile
data that needs to be updated frequently, you might want more. FLASH micros on
the market today offer anything between 1000 erase/write cycles to over 100 000
erase/write cycles. There is also plenty of creative marketing at work in
specifying those numbers, so read those datasheets carefully. Some manufacturers
specify their "100k" erase/write cycles only at room temperature and in the fine
print this number goes down to 10k over temperature, while others guarantee 100k
cycles over the entire temperature range.

Security

Another aspect to consider when selecting a FLASH
microcontroller is security and reliability. Virtually all FLASH based
microcontrollers have built in security features that allow you to protect
program memory from un-authorized external read access (to stop those software
pirates) and against accidental re-programming of certain memory blocks (usually
boot FLASH and some parts of program memory). However, none of those security
features can prevent all possible cases of FLASH memory corruption triggered by
"undefined" microcontroller behavior. For this reason it is critical to always
use either integrated or external brown-out-detection and -reset
circuitry with any FLASH based microcontroller – a simple reset circuit won't do
the job.

What about ROM and OTP?

While FLASH offers you some significant advantages
over ROM and OTP, it might not always be the most cost effective choice.
Certainly ROM wins hands-down when it comes to cost (if you compare apples to
apples, i.e. one and the same micro with same process geometries in ROM and
FLASH implementations). So ROM will always be the technology of choice in cost
sensitive, high volume applications where the firmware has stabilized and no
software update capability is needed. You need to do the math to decide if ROM
would be more economical for you (get a quote on the mask charge ($5k...$10k),
divide that number by your projected total volume and add the result to the
device price. Is your ROM part now still cheaper than the FLASH part?).

With the advent of re-programmable FLASH parts at
comparable or only slightly higher prices, OTPs are destined to go the way of
the dinosaurs. Even though OTP memory can be implemented in a smaller silicon
area than FLASH and is thus cheaper, it's caught between a rock (ROM) and a hard
place (FLASH). For cost sensitive, high volume production ROM is the uncontested
low price leader. For lower volumes the added advantages of FLASH by far
outweigh the small price advantage of OTPs. Sure OTPs will be around for a
while, but more and more only for older microcontrollers where no equivalent
FLASH version is available. The fact that OTPs are being more and more
restricted to older process technologies and thus larger geometries also
explains the phenomenon that many older OTPs are now more expensive than their
newer FLASH cousins.