Unit - 2
Fundamentals of Microcontrollers
Fig:1 8051 Architecture
Central Processor Unit (CPU)
The brain of any processing device of the microcontroller is the CPU. It monitors and controls all operations performed on these units. It reads a program written in ROM memory, executes and does the expected task.
Interrupts
Interrupt is a subroutine call that interrupts the microcontroller's main operations or work and causes it to execute any other program, at the time of operation. It provides a mechanism to put on hold the ongoing operations, execute a subroutine and resume to another type of operation.
8051 has five interrupt sources:
INTO
● TFO
● INT1
● TF1
● R1/T1
(INT0) ̅ and (INT1) ̅ are external interrupts negative edge triggered or low level triggered. When these interrupts are activated, the corresponding flags are set except for serial interrupts.
When the processor branches to ISR the interrupt flags are cleared. The external interrupts are timer and serial port interrupts.
Memory
They require memory to save as well as read so that the microcontroller performs specific operations of the task.
The memory which is used to store the program is known as code memory or Program memory. It is also known as ROM memory.
8051 data memory is used to store data temporarily for operation known as RAM memory. It has 4K of code memory or program memory and 128 bytes of data memory of RAM.
BUS
A collection of wires that work as a communication channel or medium for transfer of data. It consists of 8, 16 or more wires of microcontroller. Thus, they carry 8 bits or 16 bits of data simultaneously. There are two types of buses which are
● Address Bus
● Data Bus
Address Bus:
Microcontroller 8051 has a 16-bit address bus for transferring data. It addresses memory locations to transfer addresses from CPU to Memory. It has four addressing modes that are:
● Immediate addressing modes.
● Bank address (or) Register addressing mode.
● Direct Addressing mode.
● Register indirect addressing mode.
Data Bus: Microcontroller 8051 has 8 bits of data bus used to carry data for applications.
Oscillator
The 8051 microcontroller has an on-chip oscillator that acts as a clock source for the CPU of the microcontroller. The output pulses of the oscillator are stable. Therefore, it enables synchronized work for all the parts of the Microcontroller system.
Input/Output Port
To control the operation of machines, microcontrollers are used in embedded systems. To connect to other machines, devices or peripherals I/O interfacing ports is required. Microcontroller 8051 has 4 input and output ports to connect to other peripherals
Timers/Counters
The 8051 microcontroller has two 16-bit timers and counters. The counters are again divided into 8-bit registers. Timers are used for measurement of time intervals to determine pulse width.
Microprocessor | Microcontroller |
Microprocessor is the heart of Computer system. | Micro Controller is the heart of an embedded system. |
It is only a processor, so memory and I/O components need to be connected externally | Micro Controller has a processor along with internal memory and I/O components. |
Memory and I/O has to be connected externally, so the circuit becomes large. | Memory and I/O are already present, and the internal circuit is small. |
You can’t use it in compact systems | You can use it in compact systems. |
Cost of the entire system is high | Cost of the entire system is low |
Due to external components, the total power consumption is high. Therefore, it is not ideal for the devices running on stored power like batteries. | As external components are low, total power consumption is less. So it can be used with devices running on stored power like batteries. |
Most of the microprocessors do not have power saving features. | Most of the microcontrollers offer power-saving mode. |
It is mainly used in personal computers. | It is used mainly in a washing machine, MP3 players, and embedded systems. |
Microprocessor has a smaller number of registers, so more operations are memory-based. | Microcontroller has more register. Hence the programs are easier to write. |
Microprocessors are based on Von Neumann model | Micro controllers arc based on Harvard architecture |
It is a central processing unit on a single silicon-based integrated chip. | It is a byproduct of the development of microprocessors with a CPU along with other peripherals. |
It has no RAM, ROM, Input-Output units, timers, and other peripherals on the chip. | It has a CPU along with RAM, ROM, and other peripherals embedded on a single chip. |
It uses an external bus to interface to RAM, ROM, and other peripherals. | It uses an internal controlling bus. |
Microprocessor-based systems can run at a very high speed because of the technology involved. | Microcontroller based systems run up to 200MHz or more depending on the architecture. |
It’s used for general purpose | It’s used for application-specific systems. |
It’s complex and expensive, with a large number of instructions to process. | It’s simple and inexpensive with less number of instructions to process. |
Most 8-bit processors are old architectures, so they tend to be slower. They are cheap. They also tend to have a low limit on supported RAM/other storage, but the actual amount depends on the family.
16-bit processors tend to focus on price as well, but there is a large range of parts available, some of which have fairly high performance and large amounts of on-chip peripherals. These parts usually perform faster than 8-bit parts on math where the precision is greater than 8 bits, and tend to have more addressable memory.
32-bit chips compete primarily on performance for an application. There is a considerable range of 32-bit parts available, each targeted at some specific application. They tend to come loaded with peripherals and compete on feature completeness. They have a large amount of addressable memory and the performance tends to be better than 16-bit parts.
An embedded system can be a computer hardware system having software embedded in it. An embedded system can be an independent system or it can be a part of a large system. An embedded system is a microcontroller or microprocessor based system designed to perform a specific task.
For example, let us consider the fire alarm as an embedded system. This system only senses smoke.
An embedded system consists of three components −
● It has hardware.
● It has application software.
● It has a Real Time Operating system (RTOS) which defines the way the system works. It sets the rules during the execution of the application program. A small scale embedded system may not have RTOS.
Characteristics of an Embedded System
● Single-functioned − An embedded system usually performs a specialized operation and does the same repeatedly. For example: A pager always functions as a pager.
● Tightly constrained − All computing systems have constraints on design metrics, but those on an embedded system can be especially tight. Design metrics is a measure of an implementation's features such as its cost, size, power, and performance
● Reactive and Real time − Many embedded systems must continually react to changes in the system's environment and must compute certain results in real time without any delay.
● Memory − It must have a memory, as its software usually embeds in ROM. It does not need any secondary memories in the computer.
● Connected − It must have connected peripherals to connect input and output devices.
● HW-SW systems − Software is used for more features and flexibility. Hardware is used for performance and security.
Fig 2.
While developing an embedded system there is an option to base the computational hardware around a microcontroller which can be a microcontroller or microprocessor.
Both approaches have their attractions but typically the microcontroller, MCU, is found in applications where size, low power and low cost are key requirements.
The MCU microcontroller is different to a microprocessor where it contains more elements of the overall processing engine within the one chip.
Most of the processing engine components are brought onto a single chip which reduces size and cost. This enables it to become economically viable to digitally control where more devices and processes take place. Also, it is found that mixed signal microcontrollers are being increasingly used, integrating analogue components needed to control non-digital electronic systems.
Microcontrollers comprise the main elements of a small computer system on a single chip. They contain the memory, and IO as well as the CPU one the same chip. This considerably reduces the size, making them ideal for small embedded systems.
Also microcontrollers are often intended for low power and low processing applications where some microcontrollers use 4 bit words and they may also operate with very low clock rates - some 10 kHz and less to conserve power. This means that some MCUs consume a milliwatt or so and they may also have sleep consumption levels of a few nanowatts.
References:
- 8051 Microcontroller: An Applications Based Introduction Book by David Calcutt, Frederick J. Cowan, and Hassan Parchizadeh
- 8051 Microcontrollers: Internals, Instructions, Programming, and Interfacing Book by Subrata Ghoshal
- C and the 8051: Building efficient applications Book by Thomas W. Schultz
- MICROCONTROLLER Book by V. Udayashankara
- The 8051/8052 Microcontroller: Architecture, Assembly Language, and Hardware Interfacing Book by Craig Steiner