Академический Документы
Профессиональный Документы
Культура Документы
RST (Reset): An input pin that acts as the master reset for the
processor. A high on this pin for at least two machine cycles while
the oscillator is running, resets the internal registers for an orderly
start up. Register values after reset are as follows:
Program Counter: 0000H, Accumulator: 00H, B register: 00H,
DPTR: 0000H, PSW: 00H, SP: 07H, Ports 0-3: FFH, SCON: 00H,
SBUF: 00H, IP: XXX00000B, IE: 0XX00000B, TCON: 00H,
TMOD: 00H, PCON: 0XXX0000B.
ON-CHIP OSCILLATOR
Writing to a port pin latches data to the port latch that drives a FET
connected to the port pin. The drive capability is 4 LS TTL loads
for ports 1-3 and 8 LS TTL loads for port 0. Internal pull-up
resistors are absent for port 0 pins (except when functioning as
external address/data bus). External pull-up resistors are necessary
while configured as output pins.
There is both “read latch” and “read pin” facilities. A read-modify-
write instruction (like CPL (complement) a port bit) reads the port
pin latch to avoid misinterpreting the logic level in case the pin is
heavily loaded.
I/O PORT STRUCTURE
Instructions that input a port bit read the pin through the read
pin latch. However, every read operation should be preceded
by a write 1 to the port pin latch. This ensures that the FET is
turned off and the pin is pulled high. A system reset sets all
the port latches and hence all port pins can be used as inputs
without explicitly setting the port latches. Thus, if a port pin
is cleared it cannot be used subsequently as an input unless
the latch is set first.
MEMORY ORGANIZATION
MEMORY ORGANIZATION
Timer Modes
M1 M0 MODE DESCRIPTION
0 0 0 13-bit timer mode
0 1 1 16-bit timer mode
1 0 2 8-bit auto-reload mode
1 1 3 Split timer mode. Timer 0: TL0 is
an 8-bit timer controlled by timer 0
mode setting bits. TH0 is an 8-bit
timer controlled by timer 1 mode
setting bits. Timer 1: Stopped.
TIMER OPERATION
TIMER OPERATION
TIMER OPERATION
TIMER OPERATION
TIMER OPERATION
Timer Control Register (TCON)
Bit Symbol Bit-address Description
TCON.7 TF1 8FH Timer 1 overflow flag. Set by
h/w whenever counter overflows.
Reset by s/w, or by h/w when
processor vectors to an ISR.
TCON.6 TR1 8EH Timer 1 run control bit. Set or reset by
s/w to start/stop counter.
TCON.5 TF0 8DH Timer 0 overflow flag.
TCON.4 TR0 8CH Timer 0 run control bit.
TIMER OPERATION
Timer Control Register ….. continued
Bit Symbol Bit-address Description
TCON.3 IE1 8BH External interrupt 1 edge flag.Set
by h/w when a falling edge is
detected on INT1. Cleared by s/w,
or by h/w when processor vectors
to an ISR.
TCON.2 IT1 8AH External interrupt 1 type flag.
Set/cleared by s/w for falling-
edge/low-level activated external
interrupt.
TCON.1 IE0 89H External interrupt 0 edge flag.
TCON.0 IT0 88H External interrupt 0 type flag.
INTERRUPTS
Main Program
Interrupt-level
ISR
execution
Base-level
Main Main
execution
Time
Enabling/Disabling Interrupts
Each of the interrupt sources can be individually enabled/disabled by
setting/clearing the corresponding bit in the IE SFR at location A8H.
All interrupts can be globally disabled by clearing the global enable bit at
AFH. To enable an interrupt source two bits must be set. The individual
enable bit and the global enable bit.
For example the serial port interrupt is enabled as follows:
SETB ES ; Enable serial interrupt
SETB EA ; Set global enable bit
An alternative coding runs as follows:
MOV IE,#10010000B
INTERRUPTS
Interrupt Priority
Each interrupt source can be programmed to one of two priority levels
through IP - the bit-addressable SFR at location B8H.
IP is cleared by a system reset to place interrupts at low priority level by
default. Priority of an interrupt source is set to high by setting the
corresponding bit in the IP register.
Whenever a high priority interrupt occurs when a low priority ISR is
running, the ISR is interrupted. However, a high priority ISR cannot be
interrupted.
The main program, operating at base level, can always be interrupted. If
two interrupts occur simultaneously, the higher priority one is serviced
first.
INTERRUPTS
Interrupt Priority
When two or more concurrent interrupts occur:
• 8051 checks the priority levels first. The one with the highest priority
is serviced first.
• If two or more interrupt inputs have the same priority level, the
controller uses a fixed polling sequence to decide the one to be
serviced first. The fixed polling sequence is as follows: (i) External
Interrupt 0, (ii) Timer 0, (iii) External Interrupt 1, (iv) Timer 1, (v)
Serial Port.
INTERRUPTS
The 8051 Serial Port
Serial Port
The serial port receive and transmit registers are both accessed through a
Special Function Register SBUF at address 99H. Actually, SBUF
represents two separate buffers, a transmit buffer and a receive buffer.
Writing to SBUF loads the write-only transmit register, and reading SBUF
accesses a physically separate read-only receive register.
The serial port control register, SCON, is a bit-addressable register at
address 98H, containing the status bits and control bits. The control bits set
the mode of operation of the serial port. The status bits indicate the end of
a character transmission or reception. The status bits can be tested in
software or can be programmed to generate an interrupt.
Serial Port