Figure 4.5 A block diagram of a microcontroller
Central Processing Unit (CPU):
CPU is the brain of the computer system, administers all activity in the
system and performs all operations on data. It continuously performs two
operations: fetching and executing instructions. It understand and execute
instructions based on a set of binary codes called the instruction set.
Machine Cycle
:
To execute an instruction–the processor must:
1. Fetch the instruction from memory
2. Decode the instruction
3. Execute the instruction
4. Store the result back in the memory.
These four steps refer to Machine Cycle. Generally one machine cycle = X clock
cycles ("X" depends on the particular instruction being executed). Shorter the
clock cycle, lesser the time it takes to complete one machine cycle, so
instructions are executed faster. Hence, faster the processor.
42
Fetching and Executing an Instruction:
Fetching involves the following steps: (a) Contents of PC are placed on address
bus. (b) READ signal is activated. (c) Data (instruction opcode) are read from
RAM and placed on data bus. (d) Opcode is latched into the CPU’s internal
instruction register. (e) PC is incremented to prepare for the next fetch from
memory. While execution involves decoding the opcode and generating control
signals to gate internal registers in and out of the ALU and to signal the ALU to
perform the specified operation.
The Buses: Address, Data, and Control:
A Bus is a collection of wires carrying information with a common
purpose. For each read or write operation, the CPU specifies the location of the
data or instruction by placing an address on the address bus then activates a signal
on the control bus indicating whether the operation is read or write.
Read Operations retrieve a byte of data from memory at the location
specified and place it on the data bus CPU reads the data and places it in
one of its internal registers.
Write Operations put data from CPU on the data bus and store it in the
location specified.
ADDRESS BUS carries the address of a specified location. For n, address lines,
2
n
locations can be accessed. E.g., A 16-bit address bus can access 2
16
= 65,536
locations or 64K locations (2
10
= 1024 = 1K, 2
6
= 64).
DATA BUS carries information between the CPU and memory or between the
CPU and I/O devices.
CONTROL BUS carries control signals supplied by the CPU to synchronize the
movement of information on the address and data bus.
43
Control/Monitor (Input/Output) Devices:
Control Devices are outputs, or actuators, that can affect the world around them
when supplied with a voltage or current. Monitoring Devices are inputs, or
sensors, that are stimulated by temperature, pressure, light, motion, etc. and
convert this to voltage or current read by the computer. Note: The interface
circuitry converts the voltage or current to binary data, or vice versa.
Types of Microcontrollers:
Microcontrollers can be classified on the basis of internal bus width, architecture,
memory and instruction set. Figure 4.6 shows the various types of
microcontrollers.
4.2.5.1
The 8, 16 and 32-Bit Microcontrollers:
The 8-Bit Microcontroller: When the ALU performs arithmetic and logical
operations on a byte (8-bits) at an instruction; the microcontroller is an 8-bit
microcontroller. The internal bus width of 8-bit microcontroller is of 8-bit.
Examples of 8-bit microcontrollers are Intel 8051 family and Motorola
MC68HC11 family.
The 16-Bit Microcontroller: When the ALU performs arithmetic and logical
operations on a word (16-bits) at an instruction; the microcontroller is a 16-bit
microcontroller. The internal bus width of 16-bit microcontroller is of 16-bit.
Examples of 16-bit microcontrollers are Intel 8096 family and Motorola
MC68HC12 and MC68332 families. The performance and computing capability
of 16-bit microcontrollers are enhanced with greater precision as compared to
the 8-bit microcontrollers.
The 32-Bit Microcontroller: When the ALU performs arithmetic and logical
operations on a double word (32bits) at an instruction; the microcontroller is a
32-bit microcontroller. The internal bus width of 32-bit microcontroller is of 32-
44
bit. Examples of 32-bit microcontrollers are Intel 80960 family and Motorola
M683xx and Intel/Atmel 251 family. The performance and computing capability
of 32-bit microcontrollers are enhanced with greater precision as compared to
the 16-bit microcontrollers.
Figure 4.6 Types of microcontrollers
4.2.5.2
Embedded and External Memory Microcontrollers:
EMBEDDED MICROCONTROLLERS: When an embedded system has a
microcontroller, unit that has all the functional blocks (including program as well
as data memory) available on a chip is called an embedded microcontroller. For
example, 8051 having Program & Data Memory, I/O Ports, Serial
Communication, Counters and Timers and Interrupt Control logic on the chip is
an embedded microcontroller.
External Memory Microcontrollers: When an embedded system has a
microcontroller unit that has not all the functional blocks available on a chip is
45
called an external memory microcontroller. In external memory microcontroller,
all or part of the memory units are externally interfaced using an interfacing
circuit called the glue circuit. For example, 8031 has no program memory on the
chip is an external memory microcontroller.
4.2.5.3
Microcontroller Architectural Features:
There are mainly two categories of processors, namely, Von-Neuman (or
Princeton) architecture and Harvard Architecture. These two architecture differ
in the way data and programs are stored and accessed.
Microcontroller Applications:
In addition to control applications such as the home monitoring system,
microcontrollers are frequently found in embedded applications. Among the
many uses that you can find one or more microcontrollers: automotive
applications, appliances (microwave oven, refrigerators, television and VCRs,
stereos), automobiles (engine control, diagnostics, climate control),
environmental control (greenhouse, factory, home), instrumentation, aerospace,
and thousands of other uses. Microcontrollers are used extensively in robotics.
In this application, many specific tasks might be distributed among a large
number of microcontrollers in one system. Communications between each
microcontroller and a central, more powerful microcontroller (or microcomputer,
or even large computer) would enable information to be processed by the central
computer, or to be passed around to other microcontrollers in the system. A
special application that microcontrollers are well suited for is data logging. By
stick one of these chips out in the middle of a cornfield or up in a balloon, one
can monitor and record environmental parameters (temperature, humidity, rain,
etc.). Small size, low power consumption, and flexibility make these devices
ideal for unattended data monitoring and recording.
46
Microcontroller ATmega16:
ATmega16 is an 8-bit high performance microcontroller of Atmel’s Mega
AVR family with low power consumption. Atmega16 is based on enhanced
RISC (Reduced Instruction Set Computing) architecture with 131 powerful
instructions. Most of the instructions execute in one machine cycle. Atmega16
can work on a maximum frequency of 16MHz.
ATmega16 has 16 KB programmable flash memory, static RAM of 1 KB
and EEPROM of 512 Bytes. The endurance cycle of flash memory and
EEPROM is 10,000 and 100,000, respectively.
ATmega16 is a 40-pin microcontroller. There are 32 I/O (input/output)
lines, which are divided into four 8-bit ports designated as PORTA, PORTB,
PORTC and PORTD.
ATmega16 has various in-built peripherals like USART, ADC, Analog
Comparator, SPI, JTAG etc. Each I/O pin has an alternative task related to in-
built peripherals. The figure 4.7 shows the pin description of ATmega16.
Figure 4.7 ATmega16 Pin-out diagram
|