Embedded System Assignment 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

8051 Microcontroller

Brief History of 8051


The first microprocessor 4004 was invented by Intel
Corporation. 8085 and 8086 microprocessors were also invented by Intel. In 1981, Intel
introduced an 8-bit microcontroller called the 8051. It was referred as system on a chip because
it had 128 bytes of RAM, 4K byte of on-chip ROM, two timers, one serial port, and 4 ports (8-bit
wide), all on a single chip. When it became widely popular, Intel allowed other manufacturers to
make and market different flavors of 8051 with its code compatible with 8051. It means that if
you write your program for one flavor of 8051, it will run on other flavors too, regardless of the
manufacturer. This has led to several versions with different speeds and amounts of on-chip
RAM.
8051 Flavors / Members
8052 microcontroller − 8052 has all the standard features of the 8051 microcontroller as
well as an extra 128 bytes of RAM and an extra timer. It also has 8K bytes of on-chip program
ROM instead of 4K bytes.
8031 microcontroller − It is another member of the 8051 family. This chip is often referred
to as a ROM-less 8051, since it has 0K byte of on-chip ROM. You must add external ROM to it
in order to use it, which contains the program to be fetched and executed. This program can be as
large as 64K bytes. But in the process of adding external ROM to the 8031, it lost 2 ports out of
4 ports. To solve this problem, we can add an external I/O to the 8031.
Comparison between 8051 Family Members
The following table compares the features available in 8051, 8052, and 8031.

Feature 8051 8052 8031

ROM(bytes) 4K 8K 0K

RAM(bytes) 128 256 128

Timers 2 3 2

I/O pins 32 32 32

Serial port 1 1 1

Interrupt sources 6 8 6
Features of 8051 Microcontroller
An 8051 microcontroller comes bundled with the following features
 4KB bytes on-chip program memory (ROM)
 128 bytes on-chip data memory (RAM)
 Four register banks
 128 user defined software flags
 8-bit bidirectional data bus
 16-bit unidirectional address bus
 32 general purpose registers each of 8-bit
 16 bit Timers (usually 2, but may have more or less)
 Three internal and two external Interrupts
 Four 8-bit ports,(short model have two 8-bit ports)
 16-bit program counter and data pointer
 8051 may also have a number of special features such as UARTs, ADC, Op-amp, etc.
Block Diagram of 8051 Microcontroller
The following illustration shows the block diagram of an 8051 microcontroller

PIC Microcontroller

PIC (Programmable Interface Controllers) microcontrollers are the worlds


smallest microcontrollers that can be programmed to carry out a huge range of tasks.
These microcontrollers are found in many electronic devices such as phones, computer control
systems, alarm systems, embedded systems, etc. Various types of microcontrollers exist, even
though the best are found in the GENIE range of programmable microcontrollers.
These microcontrollers are programmed and simulated by a circuit-wizard software.

Brief History of PIC Microcontroller


PIC microcontroller was developed in the year 1993 by microchip technology. The term PIC
stands for Peripheral Interface Controller. Initially this was developed for supporting PDP
computers to control its peripheral devices, and therefore, named as a peripheral interface device.
These microcontrollers are very fast and easy to execute a program compared with
other microcontrollers. PIC Microcontroller architecture is based on Harvard architecture. PIC
microcontrollers are very popular due to their ease of programming, wide availability, easy to
interfacing with other peripherals, low cost, large user base and serial programming capability
(reprogramming with flash memory), etc.
Architecture of PIC Microcontroller
The PIC microcontroller architecture comprises of CPU, I/O ports, memory organization, A/D
converter, timers/counters, interrupts, serial communication, oscillator and CCP module which
are discussed in detailed below.
CPU (Central Processing Unit)
It is not different from other microcontrollers CPU and the PIC microcontroller CPU consists
of the ALU, CU, MU and accumulator, etc. Arithmetic logic unit is mainly used for arithmetic
operations and to take logical decisions. Memory is used for storing the instructions after
processing. To control the internal and external peripherals, control unit is used which are
connected to the CPU and the accumulator is used for storing the results and further process.
Memory Organization
The memory module in the PIC microcontroller architecture consists of RAM (Random Access
Memory), ROM (Read Only Memory) and STACK.
Random Access Memory (RAM)
RAM is an unstable memory which is used to store the data temporarily in its registers.
The RAM memory is classified into two banks, and each bank consists of so many registers. The
RAM registers are classified into two types: Special Function Registers (SFR) and General
Purpose Registers (GPR).
General Purpose Registers (GPR):
These registers are used for general purpose only as the name implies. For example, if we
want to multiply two numbers by using the PIC microcontroller. Generally, we use registers for
multiplying and storing the numbers in other registers. So these registers don’t have any special
function,- CPU can easily access the data in the registers.
Special Function Registers:
These registers are used for special purposes only as the name SFR implies. These registers
will perform according to the functions assigned to them , and they cannot be used as normal
registers. For example, if you cannot use the STATUS register for storing the data, these
registers are used for showing the operation or status of the program. So, user cannot change the
function of the SFR; the function is given by the retailer at the time of manufacturing.

Memory Organization
Read Only Memory (ROM)
Read only memory is a stable memory which is used to store the data permanently. In
PIC microcontroller architecture, the architecture ROM stores the instructions or program,
according to the program the microcontroller acts. The ROM is also called as program memory,
wherein the user will write the program for microcontroller and saves it permanently, and
finally the program is executed by the CPU. The microcontrollers performance depends on the
instruction, which is executed by the CPU.
Electrically Erasable Programmable Read Only Memory (EEPROM)
In the normal ROM, we can write the program for only once we cannot use again
the microcontroller for multiple times. But, in the EEPROM, we can program the ROM multiple
times.
Flash Memory
Flash memory is also programmable read only memory (PROM) in which we can read, write and
erase the program thousands of times. Generally, the PIC microcontroller uses this type of
ROM.
Stack
When an interrupt occurs, first the PIC microcontroller has to execute the interrupt and the
existing process address. Then that is being executed is stored in the stack. After completing the
execution of the interrupt, the microcontroller calls the process with the help of address, which
is stored in the stack and get executes the process.
I/O Ports
 The series of PIC16 consists of five ports such as Port A, Port B, Port C, Port D & Port E.
 Port A is an 16-bit port that can be used as input or output port based on the status of the
TRISA (Tradoc Intelligence Support Activity) register.
 Port B is an 8- bit port that can be used as both input and output port.
 Port C is an 8-bit and the input of output operation is decided by the status of the TRISC
register.
 Port D is an 8-bit port acts as a slave port for connection to the microprocessor BUS.
 Port E is a 3-bit port which serves the additional function of the control signals to the
analog to digital converter.
BUS
BUS is used to transfer and receive the data from one peripheral to another. It is classified into
two types such as data bus and address.
Data Bus: It is used for only transfer or receive the data.
Address Bus:Address bus is used to transmit the memory address from the peripherals to the
CPU. I/O pins are used to interface the external peripherals; UART and USART both are serial
communication protocols which are used for interfacing serial devices like GSM, GPS,
Bluetooth, IR , etc.
A/D converters
The main intention of this analog to digital converter is to convert analog voltage values to
digital voltage values. A/D module of PIC microcontroller consists of 5 inputs for 28 pin
devices and 8 inputs for 40 pin devices. The operation of the analog to digital converter is
controlled by ADCON0 and ADCON1 special registers. The upper bits of the converter are
stored in register ADRESH and lower bits of the converter are stored in register ADRESL. For
this operation, it requires 5V of an analog reference voltage.

Timers/ Counters
PIC microcontroller has four timer/counters wherein the one 8-bit timer and the remaining timers
have the choice to select 8 or 16-bit mode. Timers are used for generating accuracy actions, for
example, creating specific time delays between two operations.
Interrupts
PIC microcontroller consists of 20 internal interrupts and three external interrupt sources which
are associated with different peripherals like ADC, USART, Timers, and so on.
Serial Communication
Serial communication is the method of transferring data one bit at a time sequentially over
a communication channel.
 USART: The name USART stands for Universal synchronous and Asynchronous Receiver
and Transmitter which is a serial communication for two protocols. It is used for
transmitting and receiving the data bit by bit over a single wire with respect to clock
pulses. The PIC microcontroller has two pins TXD and RXD. These pins are used for
transmitting and receiving the data serially.
 SPI Protocol: The term SPI stands for Serial Peripheral Interface. This protocol is used to
send data between PIC microcontroller and other peripherals such as SD
cards, sensors and shift registers. PIC microcontroller support three wire SPI
communications between two devices on a common clock source. The data rate of SPI
protocol is more than that of the USART.
 I2C Protocol: The term I2C stands for Inter Integrated Circuit , and it is a serial protocol
which is used to connect low speed devices such as EEPROMS, microcontrollers, A/D
converters, etc. PIC microcontroller support two wire Interface or I2C communication
between two devices which can work as both Master and Slave device.

Oscillators
Oscillators are used for timing generation. Pic microcontroller consist of external oscillators like
RC oscillators or crystal oscillators. Where the crystal oscillator is connected between the two
oscillator pins. The value of the capacitor is connected to every pin that decides the mode of the
operation of the oscillator. The modes are crystal mode, high-speed mode and the low-power
mode. In case of RC oscillators, the value of the resistor & capacitor determine the clock
frequency and the range of clock frequency is 30KHz to 4MHz.
CCP module
The name CCP module stands for capture/compare/PWM where it works in three modes such
as capture mode, compare mode and PWM mode.
 Capture Mode: Capture mode captures the time of arrival of a signal, or in other words,
when the CCP pin goes high, it captures the value of the Timer1.
 Compare Mode: Compare mode acts as an analog comparator. When the timer1 value
reaches a certain reference value, then it generates an output.
 PWM Mode: PWM mode provides pulse width modulated output with a 10-bit resolution
and programmable duty cycle.
PIC Microcontroller Applications
The PIC microcontroller projects can be used in different applications, such as peripherals, audio
accessories, video games, etc. For better understanding of this PIC microcontroller, the following
project demonstrates PIC microcontroller’s operations.
Street Light that Glows on Detecting Vehicle Movement:
The main intention of this project is to detect the movement of vehicles on highways to switch
on a block of street lights ahead of it, and also switch off the trailing lights to conserve energy. In
this project, a PIC microcontroller is done by using assembly language or embedded C.

Street Light that Glows on Detecting Vehicle Movement by Edgefxkits.com

The power supply gives the power to the total circuit by stepping down, rectifying, filtering and
regulating AC mains supply. When there are no vehicles on highway, then all lights will turn
OFF so that the power can be conserved. The IR sensors are placed on the road to sense the
vehicle movement. When there are vehicles on highway, then the IR sensor senses the vehicle
movement immediately, it sends the commands to the PIC microcontroller to switch ON/OFF the
LEDs. A bunch of LEDS will be turned on when a vehicle come near to the sensor and once the
vehicle passes away from the sensor the intensity will become lower than the LEDs will turn
OFF

AVR Microcontroller

AVR microcontrollers are very popular, used in numerous applications, particularly in project
prototyping and also in embedded devices. This microcontroller is an 8-bit RISC (Reduced
Instruction Set Computing) architecture microcontroller in the market since 1996 which is
having SRAM, on-chip programmable flash memory, IO data space, and the EEPROM. This is
the first microcontroller in the marketplace, which has on-chip flash storage.
Types:
AVR microcontrollers are obtainable in three categories:

Tiny AVR: This microcontroller has Less memory, small in size, apt only for simpler applications.

Mega AVR: This microcontroller is the most popular ones having a good amount of memory up
to 256KB, higher no. of inbuilt peripherals and fit for modest to difficult applications.
Xmega AVR: This microcontroller is used commercially for compound applications, which
need large program memory and also high speed.
AVR microcontroller performs most of the commands in the single execution cycle. These are
around 4 times faster than PIC microcontrollers, they consume low power and can be worked in
different power saving modes. The following table shows the comparison between the three most
commonly used microcontrollers namely, 8051, PIC and AVR.
AVR is an 8-bit microcontroller appropriate to the family of RISC. In this architecture, the
instruction set of the computer are not only less in number but also faster and simpler in
operation. The other kind of classification is CISC.

Series Name Pins Flash Memory Special Feature


Tiny AVR 6-32 0.5-8 KB Small in size

Mega AVR 6-32 4-256KB Extended peripherals

DMA, Event System


Xmega AVR 44-100 16-384KB
included

AVR Microcontroller Architecture


The architecture of the AVR is shown below, it uses a “Harvard architecture” thus it has separate
buses and memories for data and program. Instructions in the program memory are performed
with a single level pipelining. While one instruction is being achieved, the subsequent instruction
is pre-fetched from the program memory. This thought allows instructions to be performed in
every CLK cycle and that suggest AVR runs at around 1 MIPS / MHz

CPU
The CPU of the AVR microcontroller is same but so simple like the one in a computer. The main
purpose of the CPU is to confirm correct program performance. Therefore, the CPU must be able
to access perform calculations, memories, control peripherals & handle interrupts. The CPUs of
Atmel’s 8-bit and 32-bit AVR are based on an innovative “Harvard architecture” thus every IC
has two buses namely one instruction bus and data bus. The CPU reads executable instructions in
instruction bus, wherein the data bus, is to read or write the corresponding data. The CPU core of
the AVR consists of the ALU, General Purpose Registers, Program Counter, Instruction
Register, Instruction Decoder, Status Register and Stack Pointer
Flash Program Memory
The program of the AVR microcontroller is stored in non-volatile programmable Flash program
memory which is just similar to the flash storage in your SD Card or Mp3 Player. The Flash
program memory is separated into two units. The first unit is the Application Flash section. It is
where the program of the AVR is stored. The second section is named as the Boot Flash section
and can be fixed to perform directly when the device is powered up. One significant fact to note
is that the microcontrollers Flash program memory has a resolution of at least 10,000
writes/erase cycles.
SRAM
The SRAM (Static Random Access Memory) of the AVR microcontroller is just like computer
RAM. While the registers are used to execute calculations, the SRAM is used to supply data
through the runtime. This volatile memory is prearranged in 8-bit registers.
EEPROM
The term EEPROM stands for Electronically Erasable Read-Only Memory is like a nonvolatile
memory, but you can’t run a program from it, but it is used as long time storage. The EEPROM
doesn’t get removed when the IC loses power. It’s a great place for storing data like device
parameters and configuration of the system at runtime so that it can continue between resets of
the application processor. One significant fact to note is that the EEPROM memory of the AVR
has a limited lifetime of 100,000 writes / EEPROM page – reads are limitless. Keep this in mind
in your application and try to keep writing to a minimum, so that you only write the small
amount of info required for your application every time you update the EEPROM.
Digital I/O Modules
The digital I/O modules let digital communication or logic communication with the AVR
microcontroller and the exterior world. Communication signals are that of TTL/CMOS logic.
Analog I/O Modules
Analog I/O modules are used to input or output analog information from or to the exterior world.
These modules comprise analog comparators and analog-to-digital converters (ADC).
Interrupt Unit
Interrupts have enabled the microcontroller to monitor particular events in the background while
performing and application program & respond to the occurrence if required pausing the unique
program. This is all synchronized by the interrupt Unit.
Timer
Most AVR microcontrollers have at least one Timer or Counter module which is used to achieve
timing or counting operations in the microcontroller. These comprise time stamping, counting
events, measuring intervals, etc.
Watchdog
All AVR microcontrollers have an internal Watchdog Timer. It has very limited useful features
comprising: distinct 128kHz CLK source, skill to reset the microcontroller and produce an
interrupt.
USART / SPI / I2C
The units like USART or SPI or I2C are used for serial communication with the exterior world.
An instance is the USART peripheral which uses the RS232 standard.

ARM Microcontroller

The ARM processors have a less number of transistors because they have a reduced instruction
set, which allows a smaller size for the IC. Thereby being space efficient also. Most of the
electronic devices such as tablets, mobiles, smart phones and other mobile devices consist of
these processors. By combining the ARM microprocessor with RAM, ROM and other
peripherals in one single chip, we get an ARM microcontroller, for example, LPC2148.

Versions and Features of ARM Microcontroller


One of the most advanced form of these microcontrollers is the cortex microcontroller,
developed by ARMv7. The cortex family is further divided as:
 Cortex Ax series
 Cortex Rx series
 Cortex Mx series
Coretex M3 Microcontroller Features
It is a 32 bit processor offering many advantages over other microcontrollers. It is a ‘harward
architecture’. For communication with Ram and Rom, this architecture provides separate
instruction buses and data buses. It consists of a 3 stage pipeline which fetches the instructions,
then decodes it and then finally executes the instruction.
The memory required for the program has been reduced and also it provides high code density
because of the usage of THUMB-2 technology in coretex-M3. For the good interrupt
performance, the core m3 is closely integrated to NVIC (Nested Vector Interrupt Controller).
 It is a Reduced Instruction Set Computing (RISC) controller. It has a high performance
CPU of 32 bits and the pipelining is done through 3 stages.
 The Thumb-2 technology has been integrated in these controllers, which means they can
handle 16 bit as well as 32 bit instructions. This technology also provides high
performance in operations and executions.
 It has low power modes. Sleep modes are also supported by it. It controls the software
efficiently and it consists of multiple domains of power.
 The NVIC, Nested Vectored interrupt controller provides low latency as well as low jitter
interrupts response. Another advantage is that there is no need of assembly programming
in it.
Comparison Between Different Versions of Cortex
The features and specifications of cortex m3, cortex m4 and cortex R4 can be compared as in the
following table:

Applications of ARM Microcontrollers


Some of the applications of the cores of the ARM have been listed in the table below:
Other than that the ARM microcontrollers can also be used in space and aerospace technologies.
Used in many medical equipment’s such as MRI, CT scanner, ultrasound and implantable
devices.
Also used at the research level in particle accelerators, nuclear reactors and X-ray cargo scanning
applications.
ARM Architectures
A 32 bit RISC Load Store Architecture is present in ARM machines. The manipulation of
memory is not possible directly; the registers are used for this purpose. Different varieties of
operations are offered by the instruction set but the main focus is to reduce the number of cycle
required for each instruction.
The instructions present in the ARM ISA are all conditional. The condition AL is accompanied
by normal execution instructions. Excluding the condition AL, 14 other conditions are also
available. The number of transistors has increased from 30000 in ARM2 to 26 million in the
cortex-A9 ARM. A Thumb architecture was also developed which supported 16 bit instructions.
Increasing the code density caused a drop in performance of these machines. But it was
compensated by Thumb 2.
THUMB
The thumb mode has been featured by the processors from ARM7TDMI to help in improving the
compiled code density. The 16 bit instructions are executed in this mode and they are mapped to
the normal ARM instructions.
The opcodes that are smaller in size show less functionality in thumb. Some opcodes cannot
access all the registers and only the branches can be opted as conditional. Smaller opcodes are
more efficient.
Usually a very small amount of RAM is accessible with a data path of 32 bit in embedded
hardware. Rest of it is accessed by a 16 bit path. Therefore it becomes logical to use 16 bit thumb
code and the wider instructions can be placed in a memory which is accessible by 32 bit. The
ARM7TDI was the first process having a thumb instruction decoder.
DSP ENHANCEMENT INSTRUCTIONS
New instruction set was added to improve the architecture of ARM for multimedia applications
and digital signal processing. These are specified by adding an E in the architecture’s name such
as ARMv5TEJ and ARMv5TE etc. these are just the variations added on count leading zeros and
saturated subtract and add operations etc.
JAZELLE
Besides the ARM and Thumb modes, a new technology has been introduced which allows the
execution of Java bytecode in hardware. This technology is known as Jazelle. It is most
prominently used in mobile phones so that the execution speed of Java EM games can be
increased. The Java Virtual Machine performs the complicated operations in software while the
Java bytecodes are usually run on hardware.
The first processor to use Jazelle was ARM926EJ-S and the architecture of ARMv5TEJ specifies
the functionality of Jazelle. The JVM software depends on the details of hardware interface so
that the JVM and hardware can develop very well together and no other software is affected.
THUMB-2
The Thumb-2 technology was introduced on ARM1156 core and it was announced in the year
2003. It increases the breadth of the instruction set by adding 32 bit instructions to the limited 16
bit instruction set of the previously mentioned technology Thumb. The code density resembling
the Thumb is achieved by the Thumb-2 and also its performance is similar to the ARM
instruction set on a memory of 32 bit.
The instruction set Thumb-2 is supported by all the ARMv7 chips. But some of the chips for
example cortex-M3 only supports the Thumb-2 instruction set.
THUMB EXECUTION ENVIRONMENT (THUMBEE)
The ThumbEE first appeared in the Cortex-A8 processor. The instruction set is increased as
compared to the Thumb-2 instruction set. Thumb EE is used for languages such as Python,
Limbo, Java, C# and Perl etc. smaller codes are outputted by the JIT compilers and there is no
significant impact on the performance.
ADVANCED SIMD (NEON)
The advanced SIMD (Single Instruction Multiple Data) also known as the NEON technology, is
a combination of 128 bit and 64 bit SIMD instruction set. It provides acceleration for the
applications of signal processing and media.
Its execution operations include decoding of MP3 audio on 10 MHz CPUs, and runs GSM AMR
(adaptive multi rate) speech codec at 13 Mhz. it supports up to 64 bit integers and also handles
games and graphics as well as audio/video processing. The SIMD in NEON can support 16
operations at a time.

You might also like