Sunteți pe pagina 1din 20

department OF

ELECTRONICS &COMMUNICATION
Presentation in
MICROCONTROLLE
R
MITTED TO: - SUBMITTED BY:-
ANISH SAXENA MANOHAR KUMAR
0112EC071051
Microcontroller :
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example : Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X

CPU RAM ROM


A single chip
Serial
I/O Timer COM
Port
Port
Microcontroller

Wednesday, December 8, 2021


Microcontroller- Intel 8051

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.
Comparison of the 8051 Family Members

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

Wednesday, December 8, 2021


Block Diagram
External interrupts
On-chip Timer/Counter

Interrupt ROM for


On-chip Timer 1 Counter
Control program
RAM Timer 0 Inputs
code

CPU

Bus Serial
4 I/O Ports
OSC Control Port

P0 P1 P2 P3 TxD RxD
Address/Data

Wednesday, December 8, 2021


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 Bytes
– 4 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
8051 CPU Registers
A (Accumulator)
B
PSW (Program Status Word)
SP (Stack Pointer)
PC (Program Counter)
DPTR (Data Pointer)

Used in assembler
instructions
8051 Flag bits and the PSW register
• PSW Register
CY AC F0 RS1 RS0 OV -- P

Carry flag PSW.7 CY


Auxiliary carry flag PSW.6 AC
Available to the user for general purpose PSW.5 --
Register Bank selector bit 1 PSW.4 RS1
Register Bank selector bit 0 PSW.3 RS0
Overflow flag PSW.2 OV
User define bit PSW.1 --
Parity flag Set/Reset odd/even parity PSW.0 P

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

Wednesday, December 8, 2021 Mahdi Hassanpour


Pins of I/O Port

• The 8051 has four I/O ports


– Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 )
– Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 )
– Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 )
– Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 )
– Each port has 8 pins.
• Named P0.X ( X=0,1,...,7 ) , P1.X, P2.X, P3.X
• Ex : P0.0 is the bit 0 ( LSB ) of P0
• Ex : P0.7 is the bit 7 ( MSB ) of P0
• These 8 bits form a byte.
• Each port can be used as input or output (bi-direction).

Wednesday, December 8, 2021
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.
System Clock Generator
External crystal oscillator

Input sysclk
circuit

8051
Original 8051 uses 12 sysclk cycles per “machine cycle”

ECE/CS-352: Embedded Microcontroller


Prof. Cherrice Traver
Systems
Serial Port (UART)
Original 8051 had one serial port

TX (transmit)

Serial
Port RX (receive)

Data sent and received serially

BAUD rate must agree between sender and receiver

Transmission modes selected using SFR


1F
Registers
Four Register Banks
Each bank has R0-R7
Bank 3

18
17

Bank 2

10
0F

Bank 1

08
07 R7
06 R6
05 R5
04
03
R4
R3
Bank 0
02 R2
01 R1
00 R0

ECE/CS-352: Embedded Microcontroller


Prof. Cherrice Traver
Systems
Special Function Registers
DATA registers

CONTROL registers

•Timers
•Serial ports
•Interrupt system
•Analog to Digital converter Addresses 80h – FFh
•Digital to Analog converter
•Etc. Direct Addressing used to access
SPRs

ECE/CS-352: Embedded Microcontroller


Prof. Cherrice Traver
Systems
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 the
interrupt 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.)
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


Timers andCounters
The 8051 comes equipped with two timers, both
of which may be controlled, set, read, and
configured individually. The 8051 timers have
three general functions:
1) Keeping time or calculating the amount of
time between events,
2) Counting the events themselves, or
3) 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/
Internal Timers
Original 8051 has 2 timers

16 bits 16 bits

TH0 : TL0 TH1 : TL1

Timer 0 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

ECE/CS-352: Embedded Microcontroller


Prof. Cherrice Traver
Systems
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


Applications: (Timer)

Timing configures the counter to count the internal clock


frequency/ 12. (E. g. if fc = 6:0Mhz, then the timer clock
will 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 external pin INTx~ must be 1.

3. Select one of 4 modes.

S-ar putea să vă placă și