AN887
APPLICATION NOTE
MICROCONTROLLERS MADE EASY
by Microcontroller Division Applications
WHAT IS A MICROCONTROLLER?
A few years ago, system control functions were implemented using logic components and were usually large, heavy boxes. Later on, microprocessors were used and the entire controller could fit onto a small circuit board. As the process of miniaturization continued, all of the components needed for a controller were built right onto one chip. By only including the features specific to the task, cost is relatively low.
A typical microcontroller has bit manipulation instructions, easy7 and direct access to I/O, and quick and efficient interrupt processing. Therefore, a microcontroller is a highly integrated device which includes, on one chip, all or most of the parts needed to perform an application control function.
Microcontrollers come in many varieties. Depending on the power and features that are needed, customers might choose a 4, 8, 16, or 32 bit microcontroller.
Figure 1. Typical MCU Block Diagram
CONTAINS
PROGRAM
AND DATA
EXECUTES PROGRAM MANAGES EVENTS
SIGNAL GENERATION EVENTCOUNTING
APPLICATION TIMEBASE
PERIPHERAL
INTERFACE
|
|
ROM |
|
|
|
|
|
CONTAINS |
|
|
|
RAM |
|
|
|
TEMPORARY |
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
DATA |
|
|
|
|
|
|
|
|
CONTAINS |
|
|
|
|
|
|
|
|
|
|
|
CPU |
|
|
|
|
|
|
|
|
|
EEPROM |
|
|
|
PERMANENT |
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
DATA |
|
|
|
|
|
|
|
|
|
|
|
TIMER |
|
A/ D |
|
|
|
ANALOG DATA |
|
|
|
|
CONVERTER |
|
|
|
ACQUISITION |
|
|
|
|
|
|
|
|
SENDS AND |
|
|
|
|
|
|
|
|
|
|
|
I/O PORT |
|
SERIAL |
|
|
|
|
|
|
|
INTERFACE |
|
|
|
RECEIVES |
|
|
|
|
|
|
|
|
DATA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VR02101A |
|
|
|
|
|
|
|
|
ROM (Read Only Memory)
ROM is usually used to store program instructions. ROM is the least expensive mean of storing a program in a microcontroller, especially for high volume manufacturing.
AN887/1100 |
1/12 |
1
MICROCONTROLLERS MADE EASY
Flash
Flash is an electrically erasable and programmable memory. It can be used instead of ROM to store program instructions and data. A key parameter of Flash memory is its endurance or the number of times it can be erased or reprogrammed. Depending on the technology used, flash endurance can be either 100 or 300,000 program/erase cycles.
RAM (Random Access Memory)
During in the execution of a program, data have to be saved for later use. Data are usually stored in RAM.
EEPROM (Electrically Erasable Programmable Read Only Memory)
There is another way to store data in a microcontroller: EEPROM is used to store data that must be saved through a power down cycle.
CPU (Central Processing Unit)
It is the brain of the system that processes all data and their travel along the bus. For example, in order to execute a program, the CPU will read the first instruction from program memory. This instruction is decoded by the CPU and executed. At the completion of the execution of the instruction, the next instruction is fetched from memory and is executed. This procedure is repeated until the end of the program (or an endless loop) is found.
Figure 2. Typical Microcontroller Block Organization
|
|
|
PROGRAM |
|
INPUT |
|
|
MEMORY |
|
BUS |
|
ROM |
||
|
|
|||
OUTPUT |
|
|
DATA |
|
PERIPHERAL |
|
|
MEMORY |
|
CENTRAL |
|
RAM |
||
SYSTEMS |
|
|||
TIMING |
EEPROM |
|||
|
PROCESSING |
|||
|
SYSTEM |
|
||
|
UNIT |
|
||
|
|
|
||
|
|
|
VR02101B |
|
TIMERS |
|
|
|
The timer or timing system makes it possible to measure and time external and internal events. The power of the timers varies greatly between different MCUs.
I / O (INPUT / OUTPUT) PORTS
Most microcontrollers have several digital I/O ports that are used to drive a LED or get a keyboard input. Usually, a port consists of eight or less bits, usually programmable as either input or output bits.
2/12
2
MICROCONTROLLERS MADE EASY
SERIAL INTERFACE
Serial interface are used to exchange data with the external world. Many microcontrollers have both asynchronous and synchronous communications peripherals built in. Usually, an asynchronous interface is called a serial communication interface (SCI or UART) while the synchronous interface is called a serial peripheral interface (SPI). A typical SCI application is to connect a PC for debugging purpose while a typical SPI application is to connect an external EEPROM.
A synchronous bus includes a separate line for the clock signal which simplifies the transmitter and receiver but is more susceptible to noise when used over long distances. With an asynchronous bus the transmitter and receiver clocks are independent, and a resynchronization is performed for each byte at the start bit.
Figure 3. Synchronous and Asynchronous Communication Principles
SYNCHRONOUS |
ASYNCHRONOUS |
CLOCK
b |
b |
b |
b |
b |
b |
b |
DATA |
|
|
|
|
|
|
|
CLOCK |
0 |
b |
b |
b |
b |
b |
1 |
+ |
Start |
|
|
|
|
|
Stop |
DATA |
VR02101C
A/D CONVERTER
Converts an external analog signal (typically relative to voltage) into a digital representation. Microcontrollers that have this feature can be used for instrumentation, environmental data logging, or any application that lives in an analog world.
Figure 4. A/D Converter Principle
Voltage |
|
|
|
|
|
|
|
|
ANALOG |
A / D |
DIGITAL |
|
|
||
|
CONVERTER |
|
|
||||
5 |
|
|
|
|
|
|
|
4 |
ANALOG |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
SIGNAL |
|
|
|
|
|
|
2 |
|
5 |
4 |
2 |
1 |
1 |
2 |
|
|
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
Time |
|
|
|
VR02101D |
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
3/12 |
MICROCONTROLLERS MADE EASY
1 TYPICAL MICROCONTROLLER APPLICATIONS
Microcontrollers are frequently found in home appliances (microwave oven, refrigerators, television and VCRs, stereos), computers and computer equipment (laser printers, modems, disk drives), cars (engine control, diagnostics, climate control), environmental control (greenhouse, factory, home), instrumentation, aerospace, and thousands of other uses. In many items, more than one processor can be found.
Figure 5. Typical MCU Applications
TV SET |
BODY CONTROLLER |
TELEPHONE SET |
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
MONITOR |
CAR RADIO |
|
KEYBOARD |
|
|
|
|
|
|
|
|
|
|
|
DASHBOAD |
|
|
|
|
FRONT PANEL |
REMOTE |
BATTERY CHARGER |
DIMMER |
REMOTE |
|
METER |
KEYLESS |
CONTROL |
SWITCH |
|
While microprocessors target the maximum processing performance, the purpose of microcontrollers is to implement a set of control function in the most cost effective way. Although controlling a microwave oven with a Pentium(TM) might seem an attractive idea, it can be easily accomplished with an ST6.
In a typical application, the MCU has to manage several tasks according to their priority or to the occurrence of external events (new command send by the keyboard, external temperature rise,...)
Figure 6. Example of MCU Task Management.
|
|
|
|
CENTRAL MCU |
|
||
|
|
|
|
|
FUNCTION |
INFORMATION |
|
KEYBOARD |
|
|
|
|
|
|
|
SCANNING |
|
|
|
|
DISPLAY |
||
|
|
|
|
|
|||
|
|
|
|
|
|||
|
|
|
|
|
|
||
MEASURE |
CHANGE |
||||||
TEMPERATURE |
TEMPERATURE |
VR02101E
The ability to manage control tasks by hardware or by software is the main performance indicator for MCUs.
4/12