Module-3
Module-3
TE(ETRX) SEM-V
Microcontrollers & Applications
By
Dr. Arun Chavan
Memory Organization
Pin Configuration
• ALU - 8 bit
• A - Register (8-Bit)
• B - Register (8-Bit)
Quiz
• The SFRs for the two timer/counters are TL0 (8Ah) and TH0 (8Ch) for
Timer/Counter 0 while TL1 (8Bh) and TH1 (8Dh) for the Timer/Counter 1.
• TCON (88h) and TMOD (89h) control their operation & modes.
• There are four modes of operation of the two timer/counters set by TMOD
TMOD:
Timer/Counter of 8051
TCON:
Mode 0:
Mode 1:
Mode 2:
Mode 3:
Mode 0
Simple 8-bit shift register
• Serial Data enters and exits
through RxD
• Half duplex communication
• 8 bits are transmitted/received
(LSB first)
• The baud rate is fixed at 1/12
the oscillator frequency
Mode 3
9-bit UART
• Serial Data enters and
exits through TxD & RxD
respectively
• Full duplex communication
• 11-bits are transmitted/received (1-start bit, 8-data bits, 1-user
programmable bit, 1-stop bit)
• The baud rate is given by (2SMOD/32)* [Fosc/12(256-TH1)]
Org 0000H
SJMP Start
Start:
Mov SCON, #40H ;program the serial port
Mov PCON, #00H ;program SMOD bit = 0
Mov TMOD, #20H;program timer 1 in mode 2
Mov TL1, #0FDH;load the count for 9600 baud
Mov TH1, #0FDH;load the count for 9600 baud
SETB TR1; timer 1 ON
Mov SBUF, #’S’; write the character in the SBUF register
Here: JNB TI, Here; check the interrupt register for TI
CLR TI; reset TI when found set
CLR TR1; timer 1 OFF
Stop: SJMP Stop
END Dr. Arun Chavan, Department of Electronics
and Computer Science
Serial Port of 8051
Quiz
1. Write a delay routine for 8 msec using Timer/Counter-0 of 8051, assume the OSC frequency
to be 12 MHz
2. What will be the count programmable in the serial port of 8051 for the baud rate of 4200
1. Discuss the modes of Timer/Counter of 8051 with associated SFRs & logic diagram for
internal hardware.
2. Discuss the modes of serial port of 8051 with SFRs associated
Interrupt Structure of 8051
Interrupts
• 8051 has five interrupt sources
• INT0, INT1,TF0 ,TF1 , TI/RI
All the interrupts can be enabled or disabled using the IE (interrupt
enable) register
• Higher/Lower priority for interrupts can be programmed with IP
(interrupt priority) register
Interrupt Address
• All the interrupt sources are
INT0 0003H
vectored INT1 0013H
• SFRs associated with interrupt TF0 000BH
Structure of 8051 are IE, IP TF1 001BH
& TCON TI/RI 0023H
Interrupt Structure of 8051
SFRs associated with Interrupt structure of 8051
IE (Interrupt Enable) Register
Bit Address AF AE AD AC AB AA A9 A8
PS High level priority of Serial port interrupt Low level priority of Serial port interrupt
PT1 High level priority of Timer1 interrupt Low level priority of Timer1 interrupt
PX1 High level priority of external interrupt 1 Low level priority of external interrupt 1
(INT1) (INT1)
PT0 High level priority of Timer0 interrupt Low level priority of Timer0 interrupt
PX0 High level priority of external interrupt 0 Low level priority of external interrupt 0
(INT0) (INT0)
Interrupt Structure of 8051
The interrupt system of 8051
Quiz
• Two Power saving modes are provided, Idle & Power down
Idle Mode
• Programed with D0-bit of
PCON
• CPU does not get continuous
clock
• Interrupt, Serial Port &
Timer connected from clock
• Oscillator circuit active
• Internal RAM, SFR contents
unchanged
• Terminated by hardware
interrupt or hardware reset
Dr. Arun Chavan, Department of Electronics
and Computer Science
Power Saving Modes in 8051
Quiz
1. Draw the format of SFRs IE and IP for the interrupt structure of 8051
2. Draw and explain the bits related to power saving modes in the SFR PCON of 8051
1. Discuss the interrupt structure of 8051 with SFRs and logic diagram for internal hardware
Thank You