MANOHAR 51
-
Upload
manohar-kumar -
Category
Documents
-
view
237 -
download
0
Transcript of MANOHAR 51
-
8/8/2019 MANOHAR 51
1/20
DEPARTMENT OF
ELECTRONICS &COMMUNICATION
SUBMITTED TO: - SUBMITTED BY:SUBMITTED BY:--
Mr. MANISH SAXENA MANOHAR KUMAR
0112EC071051
Presentation in
MICROCONTROLLER
-
8/8/2019 MANOHAR 51
2/20
-
8/8/2019 MANOHAR 51
3/20
8051 is made by Intel. It is one of the most widely
used microcontroller in the world. A stand alone, high performance, single chip
computer for
control applications.
Small, cheap and 40 pins.
64K program memory. 64K data memory.
Microcontroller- Intel 8051
-
8/8/2019 MANOHAR 51
4/20
Wednesday, November 17,2010
Feature 8051 8052 8031
ROM (program space in 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
Comparison of the 8051Family Members
-
8/8/2019 MANOHAR 51
5/20
Wednesday, November 17,2010
Block Diagram
CPU
On-chip
RAM
On-chip
ROM for
program
code
4 I/O Ports
Timer 0
Serial
PortOSC
Interrupt
Control
External interrupts
Timer 1
Timer/Counter
Bus
Control
TxD RxDP0 P1 P2 P3
Address/Data
Counter
Inputs
-
8/8/2019 MANOHAR 51
6/20
8051 Architecture
8051 architecture contains the following:8 bit CPU with registers A and B
16 bit program counter(PC) and data pointer(DPTR)
8 bit program status word(PSW)
8 bit stack pointer
Internal ROM of 0(8031) to 4K(8051)
Internal RAM of 128 Bytes4 register banks 00-1f
16 bytes(bit addressable) 20-2f
80 bytes of general purpose data memory 30-7f 32 I/O pins
arranged as four 8 bit ports (P0 P3)
2 16-bit timer/counters: T0 and T1
Full duplex serial data receiver/transmitter:
Control registers: TCON, TMOD, SCON, PCON, IP
and IE
2 external and 3 internal interrupt sources
Oscillator and clock circuits
-
8/8/2019 MANOHAR 51
7/20
8051 CPU RegistersA (Accumulator)B
PSW (Program Status Word)
SP (Stack Pointer)
PC (Program Counter)
DPTR (Data Pointer)
Used in assembler
instructions
-
8/8/2019 MANOHAR 51
8/20
Wednesday, November 17,2010
Mahdi Hassanpour
8051Flag bits and the PSW register PSW Register
CY AC F0 RS1 OVRS0 P--
CYPSW.7Carry flagACPSW.6Auxiliary carry flag--PSW.5Available to the user for general purpose
RS1PSW.4Register Bankselector bit 1RS0PSW.3Register Bankselector bit 0
OVPSW.2Overflow flag--PSW.1User define bitPPSW.0Parity flag Set/Reset odd/even parity
RS1 RS0 Register Bank Address
0 0 0 00H-07H
0 1 1 08H-0FH
1 0 2 10H-17H
1 1 3 18H-1FH
-
8/8/2019 MANOHAR 51
9/20
Wednesday, November 17,2010
Pins of I/O Port
The 8051 has four I/O ports
Port 0pins 32-39P0P0.0P0.7
Port 1pins 1-8 P1P1.0P1.7
Port 2pins 21-28P2P2.0P2.7 Port 3pins 10-17P3P3.0P3.7
Each port has 8 pins.
Named P0.XX=0,1,...,7, P1.X, P2.X, P3.X
Ex
P0.0 is the bit 0
LSB
of P0 ExP0.7 is the bit 7MSBof P0
These 8 bits form a byte.
Each port can be used as input or output (bi-direction).
-
8/8/2019 MANOHAR 51
10/20
Port Operations
Port 0 may serve as inputs, outputs, or as a low
Order address and data bus for external memory.
Port 1 may be used as input/output port.
Port 2 may be used as input/output or high order
address byte.
Port 3 may be used as an input/output and for
Some alternate function.
-
8/8/2019 MANOHAR 51
11/20
Prof. Cherrice Traver ECE/CS-352: Embedded MicrocontrollerSystems
System Clock Generator
Input
circuit
8051
sysclk
Original 8051 uses 12 sysclk cycles per machine cycle
External crystal oscillator
-
8/8/2019 MANOHAR 51
12/20
Serial Port (UART)
SerialPort
TX (transmit)
RX (receive)
Data sent and received serially
BAUD rate must agree between sender and receiver
Transmission modes selected using SFR
Original 8051 had one serial port
-
8/8/2019 MANOHAR 51
13/20
Prof. Cherrice Traver ECE/CS-352: Embedded MicrocontrollerSystems
Registers
0706050403020100
R7R6R5R4R3R2R1R0
0F
08
17
10
1F
18
Bank 3
Bank 2
Bank 1
Bank 0
Four Register BanksEach bank has R0-R7
-
8/8/2019 MANOHAR 51
14/20
Prof. Cherrice Traver ECE/CS-352: Embedded MicrocontrollerSystems
Special Function Registers
DATA registers
CONTROL registers
TimersSerial ports
Interrupt system
Analog to Digital converter
Digital to Analog converter
Etc.
Addresses 80h FFh
Direct Addressing used to access
SPRs
-
8/8/2019 MANOHAR 51
15/20
Interrupts
Interrupts are just special subroutines that may (or may
not) be called explicitly.If conditions are right, when an interrupt occurs, then the
processor will stop what it is doing, and jump to a specific
place in memory (decided by the Intel 8051 designers)
hooked by that particular interrupt.
It is up to the programmer to make sure that you supply a
sensible further course of action. This is called theinterrupt handler routine or interrupt service routine.
Interrupt programming
Signals or conditions generated external to the main
program
External events such as a change in a logic value
Overflow of a counter Arrival of data at the serial port.
Interrupts can be enabled or disabled by the programmer.
(Although some interrupts are non- maskable.)
-
8/8/2019 MANOHAR 51
16/20
Interrupt Control
Original 8051 has five sources of interrupts
Timer 1 overflow
Timer 2 overflow
External Interrupt 0
External Interrupt 1 Serial Port events (buffer full, buffee empty, etc)
Interrupts enabled and disabled using SFR
-
8/8/2019 MANOHAR 51
17/20
Timers andCounters
The 8051 comes equipped with two timers, both
of which may be controlled, set, read, andconfigured individually. The 8051 timers have
three general functions:
1) Keeping time or calculating the amount of
time between events,
2) Counting the events themselves, or3) Generating baud rates for the serial port. Could use
software techniques, but this keeps the
processor occupied. Better to use interrupts & the
two 16- bit count- up timers. Can either be
programmed to:
1. count internal - acting as timer
2. count external - acting as counter
All counter action is controlled by the TMOD
(timer mode register) and the TCON (timer/counter control re ister .
-
8/8/2019 MANOHAR 51
18/20
Prof. Cherrice Traver ECE/CS-352: Embedded MicrocontrollerSystems
Internal TimersOriginal 8051 has 2 timers
16 bits
TH0 : TL0
Timer 0
16 bits
TH1 : TL1
Timer 1
Timers increment on each system clock
Timer registers (TH0, TL0, TH1, TL1) can be read or written to
Timer overflow can cause interrupts or set SFR bits high
-
8/8/2019 MANOHAR 51
19/20
Timers and Counters
Applications: (counter)
Say we want to count a specified number of events (clock
pulses or external events), then
1.Store the start number in the counter. (Value maxcount
desired count+ 1)
2. Counter automatically increments (in the background)
3. When it rolls over to zero, it will set the timer flag.
4. Test the flag in the program, or generate an interrupt
-
8/8/2019 MANOHAR 51
20/20
Applications: (Timer)
Timing configures the counter to count the internal clock
frequency/ 12. (E. g. if fc = 6:0Mhz, then the timer clockwill have a frequency of 500kHz.)
To configure as a timer:
1. Clear C/T~ bit in TMOD (Count internal frequency)
2. Set TRx in the TCON (timer run) and the gate bit in the
TMOD must be 0, or the externalpin INTx~ must be 1.
3. Select one of 4 modes.