View
312
Download
0
Category
Preview:
DESCRIPTION
Introduction to Embedded Systems Embedded system – classification, Hardware Components of an Embedded system. Microcontrollers 8051 – Introduction, Architecture, Memory Organization, Instruction Set – Programming.
Citation preview
Introduction to Embedded
Systems,8051 Deepak John
SJCET-Pala
Embedded system An embedded system is a special-purpose computer system designed to perform a dedicated
function.
Applications
1. Biomedical Instrumentation – ECG Recorder, Blood cell recorder, patient monitor system.
2. Communication systems – pagers, cellular phones, cable TV terminals, fax and
transreceivers, video games and so on.
3. Peripheral controllers of a computer – Keyboard controller, DRAM controller, DMA
controller, Printer controller, LAN controller, disk drive controller.
4. Industrial Instrumentation – Process controller, DC motor controller, robotic systems,
CNC machine controller, close loop engine controller, industrial moisture recorder cum
controller.
5. Scientific – digital storage system, CRT display controller, spectrum analyser.
Architecture
Layered architecture of an Embedded System
Hardware architecture of an embedded system
Functional Blocks
Central Processing Unit (CPU)
Memory (Read only memory and Random
access memory)
Input Devices
Output Devices
Communication interfaces
Application specific circuitry
Classification of Embedded Systems
Based on functionality and performance requirements, embedded systems are classified as :
i. Stand-alone Embedded Systems
ii. Real-time Embedded Systems
iii. Networked Information Appliances
iv. Mobile Devices
i. Stand Alone Embedded Systems
work in stand-alone mode.
They take inputs, process them and produce the desired output.
Embedded systems used in process control, automobiles, consumer electronic items etc. fall
into this category.
ii. Real-time Embedded Systems
Embedded systems in which some specific work has to be done in a specific time period are
called real-time systems.
Two types Hard and Soft
iii. Networked Information Appliances
Embedded systems that are provided with network interfaces and accessed by networks such
as Local Area Network or the Internet are called networked information appliances.
iv. Mobile Devices
Mobile devices such as mobile phones, Personal Digital Assistants (PDAs), smart phones etc.
are a special category of embedded systems
Microcontrollers
Microcontrollers are small computing systems on a single chip.
A microcontroller will also be referred to as an MCU.
Central Processing Unit (CPU)
Program memory
Random Access Memory (RAM)
EEPROM - Electrically Erasable Programmable Read Only Memory
USARTs, Timer/Counters, ADC, DAC, I/O Ports, CANs, SPIs, etc.
Serial
Port
CPU RAM ROM
I/O
Port Timer A single chip
Microprocessor vs Microcontroller
Microprocessor
CPU is stand-alone, RAM, ROM, I/O,
timer are separate
designer can decide on the amount of
ROM, RAM and I/O ports.
Expansive
general-purpose
Microcontroller
CPU, RAM, ROM, I/O and timer are all on
a single chip.
fix amount of on-chip ROM, RAM, I/O ports
for applications in which cost, power and
space are critical.
single-purpose
Applications of microcontrollers
Automobile
Aeronautics
Space
Rail Transport
Mobile communications
Industrial processing
Remote sensing , Radio and Networking
Robotics
Consumer electronics , music players, Computer applications
Security (e-commerce, smart cards)
Medical electronics (hospital equipment, and mobile monitoring) and
Defense application
8051 Features
8-bit CPU
16-bit Program Counter
8-bit Processor Status Word (PSW)
8-bit Stack Pointer
Internal RAM of 128bytes
Special Function Registers (SFRs) of 128 bytes
32 I/O pins arranged as four 8-bit ports (P0 - P3)
Two 16-bit timer/counters : T0 and T1
Two external and three internal vectored interrupts
One full duplex serial I/O
Block Diagram
CPU
On-chip
RAM
On-chip
ROM for
program
code
4 I/O Ports
Timer 0
Serial
Port OSC
Interrupt
Control
External interrupts
Timer 1
Timer/Counter
Bus
Control
TxD RxD P0 P1 P2 P3
Address/Data
Counter
Inputs
Oscillator Circuit
The 8051 requires an external oscillator circuit.
The oscillator circuit usually runs around 12MHz.
The crystal generates 12M pulses in one second.
The pulse is used to synchronize the system operation in a controlled pace.
An 8051 machine cycle consists of 12 crystal pulses (clock cycle).
Pins XTAL1 & XTAL2 have been used.
Internal Memory
8051 implements a separate memory space for programs (code) and data.
Internal memory consists of on-chip ROM and on-chip data RAM.
On-chip RAM contains general purpose storage, bit addressable storage, register banks, and
special function registers.
Internal RAM
8051 CPU Registers
Register banks in the 8051 Microcontroller
Special Function Registers
8051 has 21 special function registers (SFRs) at the top of internal RAM from address 80H
to FFH.
Some SFR’s are both bit-addressable and byte addressable, depending on the instruction
accessing the register.
All 8051 CPU registers, I/O ports, timers and other architecture components are accessible
in 8051 C through SFRs
PSW (Program Status word) / Flag Register
I/O Ports
four bidirectional I/O ports. Each port has an 8-bit latch in the SFR space
To reduce the overall package pin count, the 8051 employs multiple functions for each port.
Each port also has an output drive and an input buffer.
These ports can be used to general purpose I/O, as an address and data lines.
The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins
Port 0
is 8-bit bidirectional I/O port.
is also the multiplexed low-order address and data bus during accesses to external program
and data memory.
pins no. from 32 to 39.
When used as an output the pin latches are programmed to 0.
When used as an input the pin latches are programmed to 1.
Port 1
is an 8-bit bidirectional I/0 port.
pins no. from 1 to 9.
no dual functions.
When used as an output the pin latches are programmed to 0.
When used as an input the pin latches are programmed to 1.
Port 2
is an 8-bit bidirectional I/O port.
When used as an output the pin latches are programmed to 0.
When used as an input the pin latches are programmed to 1.
pins no. from 21 to 28.
Port 3
is an 8-bit bi-directional I/0 port.
pins no. from 10 to 17.
RXD (P3.0): Serial input port,TXD (P3.1): Serial output port,INT0 (P3.2): External
interrupt,INT1 (P3.3): External interrupt,T0 (P3.4): Timer 0 external input,T1 (P3.5): Timer 1
external input, WR (P3.6): External data memory write strobe, RD (P3.7): External data
memory read strobe,
Timers and Counters
Many microcontroller applications require the counting of external events, such as frequency
of a pulse , or the generation of precise internal time delays between actions.
The 8051 has two 16-bit registers that can be used as either timers or counters.
These two up counters are named T0 and T1 and are provided for general use of the
programmer.
Each counter may be programmed to count internal clock pulses, act as a timer, or
programmed to count external events as a counter.
Both Timer/Counters have four operating modes, which Modes 0, 1 , 2 and 3
Modes are selected by bit pairs (M1, M0) in TMOD SFR
The counters are divided into two 8-bit registers called the timer low (TL0, TL1) and timer
high (TH0, TH1) bytes.
TCON (Timer/Counter Control Register)
Interrupts
Whenever any device needs its service, the device
notifies the microcontroller by sending it an interrupt
signal.
There are total 5 interrupt sources in 8051
Microprocessor as follows.
1. Timer Flag 0
2. Timer Flag 1
3. INT 0
4. INT 1, (INT 0 & INT 1 are external interrupts).
5. Serial Port Interrupt (RI or TI).
Interrupts Priorities
Pin Description of 8051 The 8051 is a 40 pin device, but out
of these 40 pins, 32 are used for I/O.
24 of these are dual purpose, i.e. they
can operate as I/O or a control line or
as part of address or data bus.
IMPORTANT PINS (I/O Ports)
Port 0 (pins 32-39):P0(P0.0~P0.7)
8-bit R/W - General Purpose I/O
Or acts as a multiplexed low byte address and data bus for external memory design
Port 1 (pins 1-8) :P1(P1.0~P1.7)
Only 8-bit R/W - General Purpose I/O
Port 2 (pins 21-28):P2(P2.0~P2.7)
8-bit R/W - General Purpose I/O
Or high byte of the address bus for external memory design
Port 3 (pins 10-17):P3(P3.0~P3.7)
General Purpose I/O
if not using any of the internal peripherals (timers) or external interrupts.
Each port can be used as input or output (bi-direction)
PSEN (out) pin 29: Program Store Enable, the read signal for external program memory
(active low).
ALE (out) pin 30: Address Latch Enable, to latch address outputs at Port0 and Port2.
EA (in) pin 31: External Access Enable, active low to access external program memory
locations 0 to 4K .
RXD,TXD: UART (pins10,11) for serial I/O on Port 3.
XTAL1 & XTAL2 (pins 19,18): Crystal inputs for internal oscillator.
Vcc(pin 40):provides supply voltage(+5) to the chip.
GND(pin 20):ground
Instruction set Arithmetic Instructions
Logic Instructions
Data Transfers
Recommended