Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Introduction To Microcontroller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Introduction To Microcontroller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

STUDY OF 8051 MICROCONTROLLER

Aim
To study the microcontroller 80
8051

controller
Architecture of 8051 Microcontroller

Architecture of 8051 microcontroller has following features

• 4 Kb of ROM is not much at all.


• 128Kb of RAM (including SFRs) satisfies the user's basic needs.
• 4 ports having in total of 32 input/output lines are in most cases sufficient to make all
necessary connections to peripheral environment.

The whole configuration is obviously thought of as to satisfy the needs of most


programmers working on development of automation devices. One of its advantages is that
nothing is missing and nothing is too much. In other words, it is created exactly in accordance
to the average user‘s taste and needs. Other advantages are RAM organization, the operation
of Central Processor
essor Unit (CPU) and ports which completely use all recourses and enable
further upgrade.
Pin out Description
Pins 1-8: Port 1 each of these pins can be configured as an input or an output.

Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of most
registers. In other words, the positive voltage on this pin resets the microcontroller. By
applying logic zero to this pin, the program starts execution from the beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output.
Besides, all of them have alternative functions:

Pin 10: RXD Serial asynchronous communication input or Serial synchronous


communication output.

Pin 11: TXD Serial asynchronous communication output or Serial synchronous


communication clock output.

Pin 12: INT0 Interrupt 0 inputs.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input.

Pin 15: T1 Counter 1 clock input.

Pin 16: WR Write to external (additional) RAM.

Pin 17: RD Read from external RAM.


Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies
operating frequency is usually connected to these pins. Instead of it, miniature ceramics
resonators can also be used for frequency stability. Later versions of microcontrollers operate at
a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.

Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are
configured as general inputs/outputs. In case external memory is used, the higher address byte,
i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb
is not used, which means that not all eight port bits are used for its addressing, the rest of them
are not available as inputs/outputs.

Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it
every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower
address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the
ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the
state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is
returned its previous logic state and P0 is now used as a Data Bus. As seen, port data
multiplexing is performed by means of only one additional (and cheap) integrated circuit. In
other words, this port is used for both data and address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that even
there is a program written to the microcontroller, it will not be executed. Instead, the program
written to external ROM will be executed. By applying logic one to the EA pin, the
microcontroller will use both memories, first internal then external (if exists).

Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as
general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE
pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0).

Pin 40: VCC +5V power supply.

Counters and Timers


As you already know, the microcontroller oscillator uses quartz crystal for its operation. As
the frequency of this oscillator is always of the same width, which makes them ideal for
time measurement. Such crystals are also used in quartz watches. In order to measure time
between two events it is sufficient to count up pulses coming from this oscillator. That is
exactly what the timer does. If the timer is properly programmed, the value stored in its
register will be incremented (or decremented) with each coming pulse, i.e. once per each
machine cycle. A single machine lasts for 12 quartz oscillator periods, which means that by
embedding quartz with oscillator frequency of 12MHz, a number stored in the timer
register will be changed million times per second, i.e. each microsecond.
The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest,
their main purpose is to measure time and count external events. Besides, they can be used
for generating clock pulses to be used in serial communication, so called Baud Rate.
Timer T0

As seen in figure below, the timer T0 consists of two registers – TH0 and TL0 representing a
low and a high byte of one 16-digit
digit binary number.

Accordingly, if the content of the timer T0 is equal to 0 (T0=0) then both registers it consists
of will contain 0. If the timer contains for example number 1000 (decimal), then the TH0
register (high byte) will contain the number 3, while the TL0 register (low byte) will contain
decimal number 232.

Formula used to calculate values in these two registers is very simple:


TH0 × 256 + TL0 = T
Matching the previous example it would be as follows:
3 × 256 + 232 = 1000

Since the timer T0 is virtually 16-bit


16 bit register, the largest value it can store is 65 535. In case
of exceeding this value, the timer will be automatically cleared
cleared and counting starts from 0.
This condition is called an overflow. Two registers TMOD and TCON are closely connected
to this timer and control its operation.
TMOD Register (Timer Mode)

The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure
below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer
to the timer 1. There are 4 operational modes and each of them is described herein.

Bits of this register have the following function:


fun

• GATE1 enables and disables Timer 1 by means of a signal brought to the INT1 pin
(P3.3):
o 1 - Timer 1 operates only if the INT1 bit is set.
o 0 - Timer 1 operates regardless of the logic state of the INT1 bit.
• C/T1 selects pulses to be counted up by the timer/counter 1:
o 1 - Timer counts pulses brought to the T1 pin (P3.5).
o 0 - Timer counts pulses from internal oscillator.
• T1M1,T1M0 These two bits select the operational mode of the Timer 1.

T1M1 T1M0 Mode Description


0 0 0 13-bit timer
0 1 1 16-bit timer
8-bit auto-
1 0 2
reload
1 1 3 Split mode

• GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2):
o 1 - Timer 0 operates only if the INT0 bit is set.
o 0 - Timer 0 operates regardless of the logic state of the INT0 bit.
• C/T0 selects pulses to be counted up by the timer/counter 0:
o 1 - Timer counts pulses brought to the T0 pin (P3.4).
o 0 - Timer counts pulses from internal oscillator.
• T0M1,T0M0 These two bits select the oprtaional mode of the Timer 0.

T0M1 T0M0 Mode Description


0 0 0 13-bit timer
0 1 1 16-bit timer
1 0 2 8-bit auto-reload
1 1 3 Split mode

Timer Control (TCON) Register


TCON register is also one of the registers whose bits are directly in control of timer
operation.
Only 4 bits of this register are used for this purpose, while rest of them is used for interrupt
control to be discussed later.

• TF1 bit is automatically set on the Timer 1 overflow.


• TR1 bit enables the Timer 1.
o 1 - Timer 1 is enabled.
o 0 - Timer 1 is disabled.
• TF0 bit is automatically set on the Timer 0 overflow.
• TR0 bit enables the timer 0.
o 1 - Timer 0 is enabled.
o 0 - Timer 0 is disabled.

Timer 1

Timer 1 is identical to timer 0, except for mode 3 which is a hold-count


count mode. It means that
they have the same function, their operation is controlled by the same registers TMOD and
TCON and both of them can operate in one out of 4 different modes.

Result:

Thus the 8051 Architecture has been studied.

You might also like