You are on page 1of 11

Microcontrollers

Definition of a microcontroller
A microcontroller (MCU) could be very summarily defined like a system of
complete control, dedicated to a particular application which is equipped with
logic functions and most of the other elements necessary to his operation.
Therefore a very restricted number of peripheral components are required. The
microcontroller is therefore as a microcomputer built in a chip.

Microcontrollers versus Microprocessors


Microcontroller differs from a microprocessor in many ways. First and the most
important is its functionality. In order for a microprocessor to be used, other
components such as memory, or components for receiving and sending data must
be added to it. In short that means that microprocessor is the very heart of the
computer. On the other hand, microcontroller is designed to be all of that in one.
No other external components are needed for its application because all
necessary peripherals are already built into it. Thus, we save the time and space
needed to construct devices.

Elements of the internal structure of a microcontroller


Inside the microcontroller, some basic elements found are:
 The memory unit
 The central processing unit
 The Input-Output unit
 Buses
 The Timer unit
 The Watchdog
 The Analogue To Digital Converter unit
 The Serial Communication unit
 The USB unit
 …

The Memory unit


Memory is part of the microcontroller whose function is to store data. The easiest
way to explain it is to describe it as one big closet with lots of drawers. If we
suppose that we marked the drawers in such a way that they can not be confused,
any of their contents will then be easily accessible. It is enough to know the
designation of the drawer and so its contents will be known to us for sure.

Memory components are exactly like that. For a certain input we get the contents
of a certain addressed memory location and that's all. Two new concepts are
brought to us: addressing and memory location. Memory consists of all memory
locations, and addressing is nothing but selecting one of them. This means that
we need to select the desired memory location on one hand, and on the other
hand we need to wait for the contents of that location. Besides reading from a
memory location, memory must also provide for writing onto it. This is done by
supplying an additional line called control line. We will designate this line as
R/W (read/write). Control line is used in the following way: if r/w=1, reading is
done, and if opposite is true then writing is done on the memory location.
Memory is the first element, and we need a few operation of our microcontroller.
The memory unit of the microcontroller contains a program memory, a RAM,
an EEPROM and registers.
The program memory contains the program, therefore the instructions to
achieve, and possibly data needed by the program (for example variables). The
program memory can be a ROM. In this case the program is sent to the
microcontroller once. The ROM is sometimes replaced by an EEPROM or flash
memory, which can be electrically written and erased. This property makes it
possible to modify the program several times.

The RAM(Random Access Memory): makes it possible to store data during the
execution of the program.

The EEPROM (Programmable Electrically Erasable Read Only Memory):


this memory can be erased and reprogrammed, like the flash. It is used to store
data, in case for example of power supply failure.

The Central Processing Unit


CPU (Central Processing Unit) it is the "brain" of the system. It is
The internal microprocessor that reads and executes the instructions
of the program stored in the program memory. Its memory
locations are called registers.

Registers are memory locations whose role is to help with performing various
mathematical and logical operations or any other operations with data wherever
data can be found. Look at the current situation. We have two independent
entities (memory and CPU) which are interconnected, and thus any exchange of
data is hindered, as well as its functionality. If, for example, we wish to add the
contents of two memory locations and return the result again back to memory,
we would need a connection between memory and CPU. Simply stated, we must
have some "way" through data goes from one block to another.

The Buses
That "way" is called "bus". Physically, it represents a group of 8, 16, or more
wires. There are two types of buses: address and data bus. The first one consists
of as many lines as the amount of memory we wish to address, and the other one
is as wide as data, in our case 8 bits or the connection line. First one serves to
transmit address from CPU memory, and the second to connect all blocks inside
the microcontroller.

As far as functionality, the situation has improved, but a new problem has also
appeared: we have a unit that's capable of working by itself, but which does not
have any contact with the outside world, or with us! In order to remove this
deficiency, let's add a block which contains several memory locations whose
one end is connected to the data bus, and the other has connection with the
output lines on the microcontroller which can be seen as pins on the electronic
component.

The Input-output unit


Those locations we have just added are called PORTS. There are several types
of ports:
- Input ports
- Output ports
- Bidirectional ports
When working with ports, we first of all choose the port, then send data to it or
receive data from it.

When working with it, the ports act like a memory location where we can read
or white. The input-output unit makes it possible to communicate with the
outside world. The user can then see of the MCU have several wearing of
input/output, which make it possible "to communicate" with the system (by the
intermediary, for example, of a keyboard).

The Serial communications unit


They are used to exchange data with the external world while using only three
cables: transmit, receive and ground. There are two types of serial
communications: asynchronous (serial communication interfaces, SCI or UART)
and synchronous (serial peripheral interface, SPI). These interfaces are used, for
example, to connect the MCU to a PC (SCI) or an EEPROM or another
microcontroller. In the case of a synchronous transmission, each bit is
synchronized by a clock signal. In the case of an asynchronous transmission, each
byte is preceded by a starting bit and ends with an end bit; that protocol makes it
possible to synchronize the transmitter and receiver. The protocol used by the
Serial Communication Interface is the RS232 protocol.
The Timer unit
It is used as an internal base time for the system, it also generates signals and
counts events or interruptions. Some microcontrollers have a watchdog timer
(watchdog): if this device is not re-initialized by the program after preset
intervals, it will consider that there is a problem in the software and causes a
hardware reset.

The A/D converter unit


Some microcontrollers are able to function with analogue signals coming from
outside. But the microcontroller itself is a logic system, able to manage only
bits. So this module first of all converts the analogue signal into a digital signal
before it is processed.
The block diagram of a microcontroller
The diagram below summarizes the working procedure of a microcontroller.
The internal architecture
All upgraded microcontrollers use one of two basic design models called
Harvard and von-Neumann architecture. Briefly, it is about two different
ways of data exchange between CPU and memory unit.

Von-Neumann architecture

Harvard Architecture

The Instruction Set


All instructions that can be understood by the microcontroller are known
as instruction set. When you write a program , you actually “tell a story”
by specifying instructions in order they should be executed. The main
restriction in this process is a number of available instructions. The
manufacturers stick to one of the two following strategies:

RISC (Reduced Instruction Set Computer)


In this case, the idea is that the microcontroller recognizes and executes only basic
operations addition, subtraction, copying etc.). All other more complicated
operations are performed by combining these (for example, multiplication
is performed by performing successive addition).

CISC (Complex Instruction Set Computer)


CISC is the opposite of RISC! Microcontrollers designed to recognize more
than 200 different instructions can do really much and are very fast. However,
one should know how to take all that such a rich language offers, which is not
easy at all…

The basic programming language defined for microcontrollers by the


manufacturers is the assembly language. But the difficulties encountered by
beginners pushed some engineers to develop compilers with C language, Basic,
Pascal …

Necessary material for the implementation of a microcontroller


system
 The microcontroller itself
 A compiler (MPLAB, MikroC, Proton…)
 A simulator (ISIS-PROTEUS)
 The power supply (generally DC 5V)
 The Oscillator
 The reset button (not compulsory)
 A microcontroller programmer
 Other electronics components

Families of microcontrollers
There are several families of microcontrollers; among them, we have:
- Motorola family
- Atmel family
- Atemega family
- PIC family
- …
Microcontroller applications
A microcontroller is a very powerful tool that allows a designer to create
sophisticated I/O data manipulation under program control. Nowadays,
microcontrollers are produced billion per year. They are integrated in all
domains of our life such as:
 Super market, in cash registers;
 Alarm clock;
 Digital camera;
 Mouse;
 Mobile phone;
 Automobile industry (safety systems, fuel injection, …);
 Traffic signals;
 Refrigerator;
 Etc.

You might also like