Embedded System Assignment 1
Embedded System Assignment 1
Embedded System Assignment 1
ROM(bytes) 4K 8K 0K
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
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.
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.
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.