8/2/2019 Micro Controllers 1 Introduction
1/46
Microcontrollers-Introduction
8/2/2019 Micro Controllers 1 Introduction
2/46
The term microprocessor first came into use at Intel in 1971 and,generally refers to the implementation of the central processor unit(CPU) functions of a computer in a single, large scale integrated circuit.
The Intel 4004 was a four bit microprocessor and led the way tothe development of the 8008 the first eight-bit microprocessor
introduced in 1972.And from here the history of microprocessors starts..8080 in 74
and so on.
8/2/2019 Micro Controllers 1 Introduction
3/46
What Is a Microcontroller?
A microcontroller is a computer on a single chip;It contains a CPU (usually called the core) and a variety of peripheralswhich assist the application.
By contrast a typical CPU, like the x86 in your PC, contains onlythe core - all peripherals, like timers and DMA controllers, are inexternal chips.
Many microcontrollers can operate with no external componentsexcept an oscillator (a crystal or ceramic resonator) - some do not evenrequire this, having an oscillator built in!
8/2/2019 Micro Controllers 1 Introduction
4/46
Almost all modern appliances includemicrocontrollers to support the friendliness
and programmability consumers expectthese days.
Microcontrollers can have a very longlife span - chips first offered in the late 70sare still chosen for many new designstoday!
8/2/2019 Micro Controllers 1 Introduction
5/46
The Micro World
Microcontrollers are classified by the number of bits in a data(not instruction) word. The most popular segment by far is the 8-bit
microcontrollers.4-bit micros were used in many high-volume appliances with
minimum computing needs.16 and 32-bit micros are much more powerful and
correspondingly larger - many 32-bit devices are designed to offerPentium-class power at a fraction of the power and price for battery-operated computers, video game consoles etc.
8-bit microcontrollers range in size from very small (only 8pins!) to very large (over 200 pins), with some large chips providing
power and expandability comparable to that of modern CPUs.
8/2/2019 Micro Controllers 1 Introduction
6/46
External Buses
Microcontrollers can be divided also into two major groups -those with and without an external bus (EB).
An external bus (offering address and data lines) enables awide variety of peripheral chips to be connected in almost anyquantity; this flexibility comes at the cost of board space, chip size,chip count, power consumption and RFI emissions..
A major advantage of EB microcontrollers for the beginner orhard-up developer is that EPROMs (in which code for EB micros isusually stored) are cheap and large in capacity; EPROMprogrammers and emulators are cheap and easy to use.
Non-EB microcontroller, whose code is stored on-chip,require custom programming equipment, which may be cheap, ormay be very expensive.
8/2/2019 Micro Controllers 1 Introduction
7/46
Program Storage
The next major distinctions between microcontrollers is the manner in whichthe program (usually called code) you create is stored.
ROMlessmicros are those with an external bus, as discussed above, whichrequire an EPROM , non-volatile SRAM or a Flash for code storage.
An OTP (One-Time Programmable) microcontroller can be programmedexactly once. If the program isn't correct, you throw it away. OTPs are the mostpopular micro type for low-volume production, where the setup cost of masking(see next) can't be justified.
In fact, an OTP is usually just an EPROM without that expensive windowed
ceramic package.
8/2/2019 Micro Controllers 1 Introduction
8/46
A masked microcontroller contains ROM that is programmed by the
factory from code you supply. Unless you work for a large company with deeppockets you'll probably never hear about masking again
Flashmicros are newer on the block. They operate similarly to OTPs,but can be re-programmed many times, usually at least 1000. This makes itfeasible to use one chip to test code changes over and over again, and avoidwastage of chips.
ROMless and Flash microsshare the advantage that the micro doesnot need to be removed from its board for the code to be changed. This is veryuseful when developing with high-pin-count SMD microcontrollers, which
generally cannot be socketed on the board.
Program Storage
8/2/2019 Micro Controllers 1 Introduction
9/46
Software Tools
Coding for micros is generally done in either the assemblylanguage or C, although other high-level languages, notably BASIC, areavailable for some families.
Assemblers are almost always supplied free by the micro'smanufacturer or a third party, and vary widely in power, while C compilersvary from free to very expensive.
8/2/2019 Micro Controllers 1 Introduction
10/46
Although assemblersdo a relatively simple job they are not bound byany ANSI standard, so they vary widely in syntax and power. A good
assembler offers nested macros with local labels, nested conditionalassembly and helpful error messages.An interesting variant of the assembler is the structured assembler,
which allows you to use flow control construct typical of a high-levellanguage, like if-then-else and switch statements, in assembly.
Ultimately your software tools must produce a file for downloading tothe micro or EPROM. This must be in a format recognized by thehardware tools (see next), usually binary(bin), hex.
Hex file is probably the most common of these, and is a simple text
file containing addresses and data.
Software Tools
8/2/2019 Micro Controllers 1 Introduction
11/46
Programming Tools
OK, you've written a program and have a hex file hot to trot -how do you get it into the micro? The easiest category to deal with isROM-less micros: you either program (burn) your code into an EPROMusing an EPROM programmer, or download it to an EPROM emulator,which plugs into your board's EPROM socket and pretends to be anEPROM.
For OTP and flash microcontroller a programmer specific to themicro family you're using is required.
8/2/2019 Micro Controllers 1 Introduction
12/46
Other Development Tools
There's one other major development tool; that's the emulator. Its job is to let you explore the internals of the microcontroller while yourprogram's running or being stepped. An emulator is usually an externalbox which communicates with custom software running on your PC via aserial port, and attaches to a pod which plugs into the micro's socket on yourboard, appearing to be the microcontroller from your circuit's point of view. Atrue emulator can run your program in real time (as fast as the micro itselfwould) and supports all of the micro's features.Because they are specific to a micro family (and the pod often to one
particular micro) emulators can be very expensive .
8/2/2019 Micro Controllers 1 Introduction
13/46
Other Development ToolsThe simulator is an increasing popular tool these days, since it offers
some of the power of a real-time emulator for little or no cost. It emulates themicro's core in software running on your PC, allowing you to run and stepthrough your program, examining and modifying register and memory contentsetc. Good simulators also let you create stimulus files, which perform I/Ochanges on the micro under simulation. Although simulators are an excellenttool for verifying and debugging sections of data-processing code, theycannot solve problems caused by unexpected real-time behavior of your
circuit.Lastly there's the monitor, which is a module you include in your code
which communicates with PC software; typically it uses a serial port to talk to asimple terminal program. Their capabilities vary widely, but it can typically
send text messages and ASCII-converted numbers to the user, allow you tofreeze the program (except perhaps for interrupt handlers) and examine andchange memory locations and peripherals. Of course, a monitor will use amicro peripheral, usually a UART if available, for communications; it won't beavailable to your code.
8/2/2019 Micro Controllers 1 Introduction
14/46
Micro Features
Supply Voltage RangeMost micros run optimally at the standard 5.0V, but some are designed specifically for
lower voltages e.g. 3.3V. Operating micros at very low voltages (from batteries or backup capacitors)is fraught with danger - a well-tested external watchdog is the best safeguard against lockups due tounpredictable voltages.The Clock
Like any computing device, a micro has a master oscillator. This can be a crystalor thecheaper but less precise ceramic resonator. Some small micros offer an internal clock, usually
driven by an RC (resistor-capacitor) network, whose frequency can vary greatly with voltage,temperature. Typical clock frequencies are 4-16MHz. The frequency doesn't give any absolutemeasure of a microcontroller's computing power (throughput), which is measured in MIPS (millions ofoperations per second), since the number of clock cycles required to execute even the simplestinstructions varies widely between cores, and some instructions take longer than others. A usefulfigure is MIPS/MHz, which indicates roughly how many MIPS of throughput are produced by each
MHz of clock speed.Higher clock speeds increase power consumption and RFI emissions.
8/2/2019 Micro Controllers 1 Introduction
15/46
Micro Features
The Reset InputMost microcontrollers have a reset. Most small and newer microcontroller will start up when
power is applied with RESET unconnected or tied to the inactive power rail, but some older familiesrequire that an RC delayor a clean pulsebe applied after power-up.
The Brown-Out DetectorThe brown-out detector resets the micro if the supply voltage falls seriously below the nominal
value, and holds it in the reset state until it rises again. This prevents unpredictable operation at lowvoltages, including EEPROM corruption.
EEPROM corruption is usually the most pressing reason to use brown-out protection;
The WatchdogA watchdog is something very good micro-based circuit should have. Many microcontrollers
include one on the chip, which must be regularly fed by your code or it will reset the micro. If yourmicrocontroller doesn't have one, use an external watchdog chip such as the Dallas 1232 or equivalent.
Most microcontrollers with watchdogs enable your code to tell if the last reset was caused by thewatchdog.
8/2/2019 Micro Controllers 1 Introduction
16/46
Micro Features
I/O PortsAll microcontrollers offer digital I/O ports, which you can use as digital input
or output. An I/O port is generally a group of up to 8 I/O lines which areaddressed together as a byte. Usually any line can be configured as an inputoroutput, with optional weak pull-up (effectively a large resistors connected toVCC) often available for inputs
It is common for I/O lines to have an alternate (special) functionrelatedto a peripheral; it's a choice whether that line is used by that peripheral or asstandard digital I/O. Some I/O lines may have higher current capacity thanothers, for driving LEDs and other heavy loads; sinking 20mA (low output) is a
typical figure for a high-current output.
8/2/2019 Micro Controllers 1 Introduction
17/46
Micro Features
InterruptsInterrupt is a fundamental concept in micros, and computers in general.
Although your program generally follows a predictable linear path through your code,various conditions (both internal and external to the chip) can cause the micro toexecute an interrupt handler, then return to your main program where it left off.Interrupts allow your code to respond to events that require urgent attention without theneed to waste time checking for that event regularly. Interrupt handlers should be as
short as possible to avoid introducing serious delays into your code, and preventingother interrupt handlers from executing. It's common for an interrupt handler to recordwhatever caused the interrupt (such as a byte received from a UART) and set a flag toindicate this to the main program.
Interrupt handlers must save any registers or memory locations that
they usewhose corruption may affect the main program; the stack is usually used forthis. Most microcontrollers allow interrupt handlers to be nested (ie an interrupt handlerinterrupted by another interrupt handler), although this may require special action onyour part and may increase the stack usage of your program. All interrupts aredisabled when your program starts, and must be enabled by your code.
8/2/2019 Micro Controllers 1 Introduction
18/46
Micro Features
TimersTimers are perhaps the most important standard microcontroller
peripheral. A timer is a counter driven by some division of the clock.Timers are either 8 or 16 bits in length, and virtually all micros offer at leastone 8-bit timer; both up and down-counting timers exist.
You can usually start and stop a timer, read and set its value and
generate a interrupt when it reaches zero (overflows), which allows you togenerate accurate time intervals. More powerful 16-bit timers offer captureand/or compare, usually both. Also common are auto-reload timers, whichautomatically reload themselves with a specified value and start again
when they reach zero, optionally generating an interrupt., which produce apulse stream with a precisely defined duty cycle (relative low and hightimes).
8/2/2019 Micro Controllers 1 Introduction
19/46
Micro Features
Analog Input and OutputSome micros, especially larger ones, have 8 or 10-bit A/D converters.
Since a micro is a very noisy environment for A/D conversion many microsallow you literally switch off other peripherals while conversions are takingplace. Most can generate interrupts when conversions are complete. A/D
converters raise the cost of micros dramatically and limit your choicegreatly, so consider using an off-chip A/D instead. If conversion speed isnot important serial A/Ds like the TLC549 can do the job withoutconsuming many I/O lines.
A few micros also offer D/A converters for analog output.
8/2/2019 Micro Controllers 1 Introduction
20/46
Micro Features
Serial InterfacesA UART (Universal Asynchronous Receiver/Transmitter) is a
peripheral that implements an asynchronous serial interface, as used
in standard RS-232 connections, so they're very handy for talking to aPC, a terminal or another micro. They all offer the same facilities - thething to sweat over is the baud rate. Some UARTs require a timer forthis while others use a separate baud rate generator driven by the
clock. 11.059MHz crystals are available simply because they allow an8051 to offer the standard baud rates!
Some micros offer an SPI (Serial Peripheral Interface) or I2C(Inter Integrated Connect) interface, both of which use a clock linerather than as assumed baud rate to regulate data movement, andare hence synchronous. Both standards allow connection to multipleperipheral chips.
8/2/2019 Micro Controllers 1 Introduction
21/46
Micro Features
EEPROM
EEPROM (Electrically Erasable Programmable
Read Only Memory) is non-volatile memory - it retains itscontents when power is removed. Some micros include asmall amount of EEPROM (often called E-squared) storage
for use by your code.The use of EEPROM requires some care. Erasingand rewriting an EEPROM location takes some time, forwhich time your code must wait if writing multiple locations,
and loss of power can corrupt an EEPROM write inprogress if the micro doesn't have an internal or externalbrownout detector.
8/2/2019 Micro Controllers 1 Introduction
22/46
Micro Features
Analog ComparatorThe inclusion of analog comparators on micros is a fairly recent, but
they can be very handy in circuits which have to interface with an analog world.
Low-Power ModesMost micros can enter one or more low-power states, where your
program does not run and very little power is drawn, for conservation ofbatteries, backup capacitors etc. The micro is "woken up" and executionresumed by a timer or external interrupt or an I/O line state change. These
modes are typically called Wait, Idle, Sleepetc, and can reduce power supplycurrent to several microamps, dependent on supply voltage and ambienttemperature.Real-Time Clocks
Some micros, especially those intended for consumer appliances,
include a real-time clock, which helps you keep track of the time of day evenwhen the micro is in a low-power mode, and runs from a separate crystal.Typically it generates an interrupt at 1/2 second intervals; the interrupt handlercan increment time-of-day counters.
8/2/2019 Micro Controllers 1 Introduction
23/46
Micro Features
Specialized Display Drivers (ex HD44780 Hitachi)Micros targeted at modern appliances using LCD and gas plasma
displays often include drivers to support them.
External PeripheralsThese are the more common chips which can be easily connected to
micros to support features they don't provide. Bus interface peripherals are bestsuited to micros with external buses, usually ROMless, due to the large numberof connections they require. Bus peripherals are divided according to the bus
design with which they are compatible, either Intel or Motorola. Both companiesintroduced bus peripherals suitable for their 8-bit CPUs in the 70s, and theirlater micros used compatible buses. Intel, Tundra and OKI offer Intel-busperipherals; Motorola and SGS-Thompson offer Motorola-bus peripherals.Beware of NMOS versions of these parts, which can have very high power
consumption. The original IBM PC was full of Intel-bus peripherals, which arestill available and work with the 8051. Serial interface peripherals can be usedwith any micro, although some provide an easy-to-use hardware interface;code to emulate this is available for all popular micros
8/2/2019 Micro Controllers 1 Introduction
24/46
Micro Features
Timer (bus interface): Contains three separate16-bit timers which can be used in various ways. UART (bus interface): Contains one or more separate UARTs. May offer handshaking lines and
FIFOs which allow bytes to be handled in groups, features not usually found in micro UARTS.May also be called an ACIA (Asynchronous Communications Interface Adapter). Quad and octal
UARTs are UARTs capable of 3Mb/s are available for special communications needs. Peripheralssupporting proprietary communications protocols (eg IBM networking) also exist. I/O extender (bus or serial interface): Provides more general digital I/O - typically 24 lines for a
40-pin package. A/D converter (bus or serial interface): Provides analog inputs. Many offer features not often
found on micros, such as a settable voltage range or 12-bit conversion. They tend to work betterthan on-micro A/D converters because they're isolated from the noisy internals of the micro.
Real-Time Clock (serial interface): A chip with its own crystal and backup battery support whichkeeps track the time of day and date. More capable than the peripheral of the same name found insome larger micros.
Non-Volatile RAM (bus or serial interface): Flash or EEPROM memory which retains its contentswhen power is removed. The bus interface offers much faster access, but serial interfaces arecheaper and suit smaller micros.
Many standard 74-series logic chips (most commonly 74HC CMOS) can work with micro busesor be used to reduce I/O requirements. For example, the 74HC574 octal latch can provide 8 digitaloutputs and the 74HC595 shift register can be used to drive any number of digital outputs from
just three micro outputs, albeit
Mi A hit t
8/2/2019 Micro Controllers 1 Introduction
25/46
Micro Architecture
Basic Types There are two basic types of architecture to be found in micros: The Harvardarchitecture locates the code and data storage areas (memory
spaces) on separate buses, which allows instructions and data to be fetchedsimultaneously by the core, improving efficiency. The Von Neumannarchitecture puts all memory spaces on the same bus, so every
location in every space must have a unique address. This enables every space tobe treated identically as instructions or data, which has some interestingpossibilities, but is less efficient. PC architectures, where memory locations can't
be pre-wired as RAM or ROM, are Von Neumann.
8/2/2019 Micro Controllers 1 Introduction
26/46
Micro Architecture
CISC and RISC In parallel with the interest in CISC (complex instruction set
computer) for large CPUs came RISC (reduced instruction setcomputer) architectures for micros. The hallmark of a RISC micro isthat instruction words are more than 8 bits long (eg 12, 14 or 16 bits)and most instructions only require one word, whereas conventionalCISC micros have 8-bit instruction words and many instructions thatrequire more than one of them.
Generally RISC micros are designed for speed, and sacrifice someease of use to that end, but the difference in ease of use isn't sogreat that it should influence your choice of micro. You're more likelyto pick a PIC or AVR RISC micro for its speed than reject it because
its instruction set is small or appears strange.
8/2/2019 Micro Controllers 1 Introduction
27/46
Micro Architecture
To Accumulate Or Not To Accumulate The major difference to be found when comparing the instruction
sets of micros is that some require that most arithmetic and logicaloperations be performed on a single register, usually called theaccumulator, while others allow any of a number of registers to beused.
The advantage of the accumulator approach is that instructions
using it can be short, mostly 8 bits, whereas non-accumulator coresrequire a longer instruction word or multiple instruction bytes tospecify the operation. However, accumulator cores are poor at multi-byte (eg 16, 24 or 32-bit) data operations because every byte mustpass through the accumulator.
Since non-accumulator designs suit the wider instruction words ofRISC cores they'll probably become more common. They chewcode space more quickly and don't make a major difference toperformance unless a lot of multi-byte processing is required. TheAtmel AVR and Zilog Z8 are examples of non-accumulator cores.
8/2/2019 Micro Controllers 1 Introduction
28/46
Micro Architecture
Spaces Some subset of the following spaces is found in all micros: Code: Where your program is stored.
Data: RAM locations available to your program. The I/O space may bemapped into this space rather than separate.
Registers: May be mapped into the Data space or made entirely separatein RISC-type architectures. Access to registers is faster and more capablethan access to Data.
I/O: Special locations which form the program's interface with Port I/O andperipherals.
ROMless micros also possess an external space for access to the externalbus, which may be separate or mapped into the single Data space.
Understanding the spaces understood by a micro and their functions is thebasic step in coming to grips with its architecture.The 8051 is an example ofa core with a variety of spaces, all of which must be understood to makeeffective use of it.
8/2/2019 Micro Controllers 1 Introduction
29/46
Micro Architecture
The Stack All micros have a stack - a dynamic RAM area onto which return addresses
are pushedwhen you call a routine or an interrupt handler is invoked, and
off which they are poppedwhen these routines finish. Some very smallmicros with very a small Data space implement a special small space forthe stack (termed a hardwarestack) which may be as small as 3 locations,severely limiting the nesting of routine calls and interrupt handlers allowed!Most micros require you to set a stack pointerat startup, which is then usedas a base for the stack, which grows upward or downward (make sure youknow which).
If RAM space is tight, work out what the maximum possible stack size is,and reserve space for it accordingly. Corruption of the stack by other data(or vice versa) can be tough to track down, so it's better to be cautious here.
Most micros allow you to push and pop data onto and off the stack yourself.Apart from saving registers in interrupt handlers, the stack can often beuseful when you're short of registers and need to temporarily save theirvalues.
Choosing a Micro
8/2/2019 Micro Controllers 1 Introduction
30/46
Choosing a Micro
Picking the right micro for the job is something that thousands ofengineers with many years of experience mull over every day - itcan be a tough don't have time to learn something new. These are
things to consider: Availability and cost: The micro must be readily available - most
are from a single manufacturer, but multiple distributors dependingon your location. And it must be sensibly priced - prices can varyinsanely within a family depending on demand, supply andpopularity.
Support: Is the micro from a popular family? Ask people if they'drecommend it . Is the local distributor helpful and (ideally) willing tolend you tools to get you hooked on it? What's the manufacturer's
website like? Be very cautious with Asian manufacturers - they havesome wonderful micros, but they simply don't care about yourproblems unless you're using millions. NEC and Hitachi areexceptions to this.
8/2/2019 Micro Controllers 1 Introduction
31/46
Choosing a Micro
Tools Decide whether you want an emulator, which is usually far more expensive than a simpleprogrammer. If tools cost is the driving factor serial programmers for flash micros (eg H8, AVR)are unbeatable.
Variety: If you invest time and money in a new family, it's a bonus if they are useful down the
track. Get an overview of all the micros that use that core and tools, and see if you like the view.The 8051 is untouchable for variety, with the HC05 doing well at the smaller end of town. Reliability: New families (and even new parts in established families) can have problems, usually
in hardware rather than software. Don't use a new part if you can't accept some risk. Flexibility: If you want to leave room to add more memory or peripherals later, consider ROMless
micros. You can hang anything off them you can think of. Package: It must be easy to handle given your manufacturing expertise and programming tools.
Don't pick a QFP (quad flat pack) chip unless you have the equipment and knowhow to handle it.DIP and PLCC are both socketable and easy to handle (DIP more so). If you need a lot of I/O butwant to avoid surface mount, ROMless micros with 24-line I/O expanders or HC574 latches areyour guys. Unfortunately the level of micro power at which packages become surface mount isdecreasing as industry demands miniaturisation, so your choice of newer parts may be limited.
Noise Immunity: In the mains appliance industry, where I've spent some time, this is right up
there with cost. Micros very greatly in their resistance to the electrical crud that enters at powersupplies and cabling, sneaks through any attempts at filtering . The ST6 family is superb at this,the Z8 very poor, with most somewhere in between.
8/2/2019 Micro Controllers 1 Introduction
32/46
Developing For Micros
Developing code for a micro is nothing like programming a PC, except onrare large projects using very high-end chips. While PC tools now offer easeof use and high levels of abstraction, at the cost of memory consumption
and speed, fast execution and compact code remain the primaryrequirements of most micro projects, hence the continuing dominance ofassembly code. Unlike PCs, which have no practical memory limitations or(in user mode) real-time requirements, you usually need to keep thecode, RAM size and speed of micros in mind when coding for them.
It's very desirable that the person writing the micro's code also designsthe circuit in which the micro is to live, since if it's designed with thelimitations and interfacing needs of the micro in mind it will make theprogrammer's job much easier, not to mention possible!
Many micro applications must respond to external stimuli in real time- thatis, with a guarantee maximum response time or latency. If this applies to
your application consider each such requirement carefully in the context ofthe speed of your micro and the other tasks it must manage.
Real-time response should be based on interrupts if possible, since theresponse latency is guaranteed by the micro's architecture.
8/2/2019 Micro Controllers 1 Introduction
33/46
Developing For Micros
Micro code has no "exit point" - what would it exit to? There must be an outer loop,usually called the main loop, which is repeatedly executed forever. Most applicationsrequire multiple tasks to be performed simultaneously. Although multi-tasking kernelsfor micros do exist, their overhead and expense is usually only justifiable on large
projects and high-end parts. It's common practice for the main loop of a microapplication to call routines to service a number of tasks in rapid succession; ifinterrupt handlers are invoked they effectively eat into the processing poweravailable.
If you are using a C compiler, beware of 16-bit default integer and constant sizes -the overhead of 16-bit arithmetic is very high in most 8-bit micros. Look at thegenerated assembly code often to gain a feel for how you can help the compileroptimize your code without sacrificing too much of the high-level abstraction youdesire. Write interrupt handlers and other time-critical code sections inassembler.
In assembler, adopt and try to stick to some coding conventions to make your codemore reliable. Give every routine a header describing what it does, any side-effectson peripherals or RAM, what's passed and returned and what registers are used for..Divide your code into small logical blocks separated by blank lines, and put labels ontheir own lines. Only use non-descriptive label names where the jump is very short.
8/2/2019 Micro Controllers 1 Introduction
34/46
Debugging
It would be great if micro development was simply a matter ofdownloading the code, verifying that it works correctly and movingon to the next project. Unfortunately, bugs are inevitable. Some are
due to simple coding mistakes (more common in assembly), someare due to interactions between tasks you didn't expect or too-largeresponse latencies, and some are due to the hardware that the databook forgot to mention.
Firstly, don't try to write all the code in one session. Workincrementally, getting things happening in small stages. That wayyou'll always have working code to fall back on when things gowrong. Step through newly written code in a simulator if possible tocheck that it works and doesn't have unwanted side effects. It'smuch better to write and verify a piece code slowly and carefully,before ever running it for real, than to try to fix it later when it'sobscured by other functionality.
8/2/2019 Micro Controllers 1 Introduction
35/46
Core and Family Details
8051 First offered by Intel in the late 70s, this core is at the heart of the biggest variety of micros,from several manufacturers. Philips was the biggest player in the 8051 market. The 8051 has aHarvard architecture (code and internal data both start from 0).
General pros:Powerful bit manipulation instructions - part of RAM and many special registers are bit-addressable.Multiply and divide instructions.At least two 16-bit timers.UARTPlentiful internal RAM.
Straightforward code addressing - always starts at zero.I/O design makes bi-directional I/O easy.Excellent free assembler from Metalink for ex.General cons:Very quirky instruction set
Confusing variety of internal and external memory spaces.I/O design prevents true floating inputs, and pins are always high after reset.Not very fast due to clock division.Access to external data very weak - single pointer register only.The 8051 is very comfortable to use once you've learnt it. It works well for modest assembly projectswhich don't use external RAM heavily.
8/2/2019 Micro Controllers 1 Introduction
36/46
Core and Family Details
Varieties The generic ROMless 80C31 and 80C32 (avoid the old room-
heating NMOS versions without the 'C') are a bargain, even with thecost of an EPROM considered, and very flexible due to the widevariety of peripherals that it can easily address. Philips(NXP) has avery wide range, from very fast 24-pin parts to large chips with avariety of specialised peripherals. Prices and availability vary widely,though.
Dallas (Maxim) have a range using a core faster than standard forthe same clock - it divides the clock by 4 or less rather than 12.
Atmel used the 8051 core for their first small flash micros. The89C2051 (80C32 core) is remarkable - a 20-pin micro with a UART,
three 16-bit timers and 256 bytes of RAM was unheard of when itwas introduced.
8/2/2019 Micro Controllers 1 Introduction
37/46
Core and Family Details
Z8 The Zilog Z8 core is not new, but a family of small OTP parts oriented at the low-cost consumer
market is more recent. General Pros:
Cheap true emulator available, handles 18-40 pin parts. Non-accumulator instruction set. Moveable register "window" into RAM. Powerful instruction set. Two timers in all but smallest part. Watchdog standard. Two analog comparators standard. Wide range of 18-pin parts. General Cons: Poor noise immunity. No A/D in small parts
No RESET pin Slow Timers 8-bit only. Very pleasant to use, although poor noise immunity is a serious problem in some applications.
The very cheap true emulator makes it an ideal beginner's micro for someone prepared to spend alittle money. Zilog's patchy support and pricing may be of concern to corporate users.
8/2/2019 Micro Controllers 1 Introduction
38/46
Core and Family Details
AVR The AVR core promises speed at one instruction per clock cycle. Like their 8051-based family
(from Atmel) all AVR micros are flash-based, and free programmers are already around. Atmelclaim that the AVR was designed in consultation with C compiler vendors.
General Pros: Flash based, programming specs published. Inputs have optional pullup and 20mA sink capability. Very high speed (almost 1MIPS/MHz) Large register space. All data processing register-to-register: no accumulator.
Instruction set as powerful as possible given opcode space. Three RAM address pointers with auto increment/decrement. Watchdog and EEPROM standard. 1Mb/s UART on all but smallest member. No reset circuit required.
Separate I/O output latch and input pin registers. Excellent C compiler support. Able to address >64K code and data.
8/2/2019 Micro Controllers 1 Introduction
39/46
Core and Family Details
General Cons: Some odd restrictions on instruction usage.
Apparent redundancy in instruction set. Instruction set not "clean" - hard to learn. Limited bit manipulation. No brown-out detector. Free assembler from Atmel is quite weak,
Like the 8051, very capable when all theinstruction set and memory space quirks areunderstood.
C d F il D il
8/2/2019 Micro Controllers 1 Introduction
40/46
Core and Family Details
PIC Microchip's RISC family has been around a few years now. It has become
very popular through aggressive OTP pricing, a simple instruction set,
robust hardware (e.g. brown-out detectors) and excellent support. Pros compared to AVR: Standard brown-out detector. Wide range of sizes and peripheral choices. More language and tool choices. Running at published clock speeds. Cons compared to AVR: 4 times slower at same clock speed. Much weaker instruction set.
Limited code and data addressing. No C compiler support. Single I/O in/out register. Accumulator-based data processing.
C d F il D il
8/2/2019 Micro Controllers 1 Introduction
41/46
Core and Family Details
68HC05 The old faithful of the low-end 8-bit market, Motorola's (Freescale) HC05
looks rather dated these days, but some of the variants, most of which
began life as customer-specific designs, offer excellent value for particularapplications. General Pro: Von Neumann architecture is easy to understand. Straightforward instruction set with some bit handling.
Excellent support from Motorola. General Con: Weak timers. No consistency within family - many variants specialised.
No push/pop access to stack. Evaluation board (EVB) is expensive but unreliable. Not price-competitive. Slow
C d F il D t il
8/2/2019 Micro Controllers 1 Introduction
42/46
Core and Family Details
68HC11 A very popular family from Motorola (Freescale), more powerful than
the HC05, and competitive with the 8051.
General Pros: Von Neumann architecture is easy to understand. Powerful, easy-to-use instruction set. Popular parts are good value. Good support for C compilers. Good support from Motorola. General Cons: Much smaller range than 8051 derivatives. Slow UART.Overall: Probably easier to learn than the 8051, and a little more powerful,
but less variety of derivatives.
C d F il D t il
8/2/2019 Micro Controllers 1 Introduction
43/46
Core and Family Details
78K0 NEC's 78K0 is one of the more notable Japanese families to gain
popularity outside Asia. Although emulator is expensive and the
docs are poor, you get a decent free C compiler . General Pros: Very powerful instruction set with excellent C support. Some 16-bit data instructions.
Fairly fast. Abundant timers on most parts. Free C compiler and structured assembler from NEC. Good value
General Cons: Most parts surface mount. Emulator very expensive Poor documentation.
C d F il D t il
8/2/2019 Micro Controllers 1 Introduction
44/46
Core and Family Details
H8 The H8 family (really a group of 8-bit and 16-bit families) is Hitachi's
(Renesas-Hitachi and Mitsubishi) mass-market offering. Similar in
architecture to the HC05 at the low end, they are notable for their earlyadoption of flash code and the (by all accounts) excellent free port of the Ccompiler.
General pros: Many devices with flash.
Powerful instruction set with good C support. Wide range of 8 and 16-bit devices. Good free C compiler Nice evaluation/programming boards available.
Abundant timers. General cons: Most packages surface-mount. Emulator expensive.
C d F il D t il
8/2/2019 Micro Controllers 1 Introduction
45/46
Core and Family Details
ST6 The SGS-Thompson ST6 is a low-end OTP/mask family aimed squarely at
consumer devices. Its major features are excellent noise immunity and A/D
conversion on some very small parts. General Pros: Excellent noise immunity. EPROMs available throughout range for development. A/D converters available on low-end parts. Very good pricing at high volumes. General Cons: Weak instruction set makes them unpleasant to use. Starter kit is weak, and emulation is expensive.
Poor quality European docs. In the appliance industry noise immunity and low cost make any other fault
forgivable. The instruction set is weak and the architecture is confusing,especially on larger parts, but that doesn't put off serious users. It is notrecommended to beginners.
Core and Family Details
8/2/2019 Micro Controllers 1 Introduction
46/46
Core and Family Details
Others There a several general-purpose micro families
from U.S. mfrs that are not in widespread use,but tools and support are available should theyhave features you really need. Otherwise it's
best to steer clear of them. TMS370: Texas Instruments' general-purposefamily. A good range with very capable timers,but the very non-standard assembler is hard touse. Largely confined to the auto industry.
COP8: National Semiconductor's general-purpose family.