What is a Microcontroller
What is a Microcontroller
A Microcontroller is a programmable digital processor with necessary peripherals. Both microcontrollers and microprocessors are
complex sequential digital circuits meant to carry out job according to the program / instructions. Sometimes analog input/output
interface makes a part of microcontroller circuit of mixed mode(both analog and digital nature).
A microcontroller can be compared to a Swiss knife with multiple functions incorporated in the same IC
Microcontrollers Vs Microprocessors
1. A microprocessor requires an external memory for program/data storage. Instruction execution requires movement of data
from the external memory to the microprocessor or vice versa. Usually, microprocessors have good computing power and
they have higher clock speed to facilitate faster computation.
2. A microcontroller has required on-chip memory with associated peripherals. A microcontroller can be thought of a
microprocessor with inbuilt peripherals.
3. A microcontroller does not require much additional interfacing ICs for operation and it functions as a stand alone system.
The operation of a microcontroller is multipurpose, just like a Swiss knife.
4. Microcontrollers are also called embedded controllers. A microcontroller clock speed is limited only to a few tens of MHz.
Microcontrollers are numerous and many of them are application specific.
At times, a microcontroller can have external memory also (if there is no internal memory or extra memory interface is required).
Early microcontrollers were manufactured using bipolar or NMOS technologies. Most modern microcontrollers are manufactured
with CMOS technology, which leads to reduction in size and power loss. Current drawn by the IC is also reduced considerably from
10mA to a few micro Amperes in sleep mode(for a microcontroller running typically at a clock speed of 20MHz).
Harvard vs. Princeton Architecture
Many years ago, in the late 1940's, the US Government asked Harvard and Princeton universities to come up with a computer
architecture to be used in computing distances of Naval artillery shell for defense applications. Princeton suggested computer
architecture with a single memory interface. It is also known as Von Neumann architecture after the name of the chief scientist of the
project in Princeton University John Von Neumann (1903 - 1957 Born in Budapest, Hungary).
Harvard suggested a computer with two different memory interfaces, one for the data / variables and the other for program /
instructions. Although Princeton architecture was accepted for simplicity and ease of implementation, Harvard architecture became
popular later, due to the parallelism of instruction execution.
Princeton Architecture (Single memory interface)
Cycle1
-Complete previous instruction
- Read the "Move Data to Accumulator" instruction
Cycle2
- Execute "Move Data to Accumulator" instruction
- Read next instruction
Hence each instruction is effectively executed in one instruction cycle, except for the ones that modify the content of the program
counter. For example, the "jump" (or call) instructions takes 2 cycles. Thus, due to parallelism, Harvard architecture executes more
instructions in a given time compared to Princeton Architecture.
Memory types
In a microcontroller, two types of memory are found. They are, program memory and data memory respectively.
Program memory is also known as 'control store' and 'firm ware'. It is non-volatile i.e, the memory content is not lost when the power
goes off. Non-volatile memory is also called Read Only Memory(ROM). There are various types of ROM.
1. Mask ROM: Some microcontrollers with ROM are programmed while they are still in the factory. This ROM is called Mask
ROM. Since the microcontrollers with Mask ROM are used for specific application, there is no need to reprogram them.
Some times, this type of manufacturing reduces the cost for bulk production.
2. Reprogrammable program memory (or) Erasable PROM (EPROM): Microcontrollers with EPROM were introduced in
late 1970's. These devices are electrically programmable but are erased with UV radiation. The construction of a EPROM
memory cell is somewhat like a MOSFET but with a control and float semiconductor as shown in the figure.
Fig 3.3 Structure of an EPROM
In the unprogrammed state, the 'float' does not have any charge and the MOSFET is in the OFF state. To program the cell, the
'control' above the 'float' is raised to a high enough potential such that a charge leaks to the float through SiO 2 insulating layer.
Hence a channel is formed between 'Source' and 'Drain' in the silicon substrate and the MOSFET becomes 'ON'. The charge in the
'float' remains for a long time (typically over 30 years). The charge can be removed by exposing the float to UV radiation. For UV
erasable version, the packaging is done in a ceramic enclosure with a glass window.
Microcontroller can have ability to perform manipulation of individual bits in certain registers(bit manipulation). This is a unique
feature of a microcontroller, not available in a microprocessor.
Eight bits make a byte. Memory bytes are known as file registers.
Registers are some special RAM locations that can be accessed by the processor very easily.
Processor stacks store/save the data in a simple way during program execution. Processor stack is a part of RAM area where the
data is saved in a Last In First Out (LIFO) fashion just like a stack of paper on a table. Data is stored by executing a 'push'
instruction and data is read out using a 'pop' instruction.
I/O Registers:
In addition to the Data memory, some special purpose registers are required that are used in input/output and control operations.
These registers are called I/O registers. These are important for microcontroller peripheral interface and control applications.
Hardware interface registers (I/O Space)
As we already know a microcontroller has some embedded peripherals and I/O devices. The data transfer to these devices takes