0% found this document useful (0 votes)
22 views9 pages

MP Project

This document provides information about an assignment for a microprocessor-based system design course. The assignment involves writing an assembly language program (ALP) using an 8051 microcontroller for a timer/counter. It explains the steps to program the timer in mode 2, including setting the value of the TMOD register to select Timer 0, mode 2 and the 8051 crystal clock source. It also describes calculating time delays using timers and provides details on the TMOD and TCON registers that control timer functions and modes. The aim is to write an ALP to start and stop Timer 0 in mode 2 to create a time delay.

Uploaded by

Free Fire
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)
22 views9 pages

MP Project

This document provides information about an assignment for a microprocessor-based system design course. The assignment involves writing an assembly language program (ALP) using an 8051 microcontroller for a timer/counter. It explains the steps to program the timer in mode 2, including setting the value of the TMOD register to select Timer 0, mode 2 and the 8051 crystal clock source. It also describes calculating time delays using timers and provides details on the TMOD and TCON registers that control timer functions and modes. The aim is to write an ALP to start and stop Timer 0 in mode 2 to create a time delay.

Uploaded by

Free Fire
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/ 9

DEPARTMENT OF INFORMATION TECHNOLOGY

SEMESTER: 4

21UIT406-MICROPROCESSOR BASED
SYSTEM DESIGN

NAME : F.ABDUL RASITH


DEPT : IT – A
REG NO : 921722108002
ROLL NO: 22IT143
ASSIGNMENT 1

SI.NO CONTENTS CO MARK ALLOCATION(40)


1. Problem Identification &
CO3
analysis
2. Implementation & CO4
Demonstration
3. Evaluating Problems CO5

4. Modern tool usage CO6

Total

RUBRICS FOR LEVEL OF PERFORMANCE - ASSIGNMENT 1:

Excellent Good Satisfactory Needs


Criteria
(10) (8) (5) Improvement (2)

Problem
Identification
& analysis

Implementation
&
Demonstration

Evaluating
Problems

Modern tool usage


1) To Write an ALP using 8051 for Timer / Counter and to Find the
value for TMOD if we want to program Timer 0 in mode 2, use 8051
XTAL for the clock source, and use instructions to start and stop the
timer.

Aim:
To Write an ALP using 8051 for Timer / Counter and to Find the
value for TMOD if we want to program Timer 0 in mode 2, use 8051
XTAL for the clock source, and use instructions to start and stop the
timer. And also

Solution:

The role of the TMOD register, we will look at the timer’s modes
and how they are programmed
to create a time delay.
Because modes 1 and 2 are so widely used, we describe each
of them in detail.
Mode 1 programming
The following are the characteristics and operations of mode 1:
1)It is a 16-bit timer; therefore, it allows values of 0000 to FFFFH to be
loaded into the timer’s registers TL and TH.

2)After TH and TL are loaded with a 16-bit initial value, the timer must
be started. This is done by “SETB TRO” for Timer 0 and “SETB TR1″
for Timer 1.

3)After the timer is started, it starts to count up. It counts up until it


reaches its limit of FFFFH.
4)When it rolls over from FFFFH to 0000, it sets high a flag bit called TF
(timer flag).
This timer flag can be monitored. When this timer flag is
raised, one option would be to
stop the timer with the instructions “CLR TRO” or “CLR
TR1″, for Timer 0 and
Timer 1, respectively.
Again, it must be noted that each timer has its own timer flag: TFO
for Timer 0, and TF1 for Timer 1.
1. After the timer reaches its limit and rolls over, in order
to repeat the process the registers
2. TH and TL must be reloaded with the original value, and
TF must be reset to 0.
Steps to program in mode 1
To generate a time delay, using the timer’s mode 1, the following
steps are taken.

• Load the TMOD value register indicating which timer (Timer 0 or


Timer 1) is to be used and which timer
mode (0 or 1) is selected.
1. Load registers TL and TH with initial count values.
2. Start the timer.
• Keep monitoring the timer flag (TF) with the “JNB
TFx, target” instruction to see if it
is raised. Get out of the loop when TF becomes high.
3. Stop the timer.
4. Clear the TF flag for the next round.
5. Go back to Step 2 to load TH and TL again.
To calculate the exact time delay and the square wave frequency
generated on pin PI .5, we need to
know the XTAL frequency. See Example 9-5.
Develop a formula for delay calculations using mode 1 (16-bit) of
the timer for a crystal frequency of
XTAL = 11.0592 MHz. This is given in Figure 9-4. The scientific
calculator in the Accessories
directory of Microsoft Windows can help you to find the TH, TL
values.
This calculator supports decimal, hex, and binary calculations.
(a) in hex
(FFFF – YYXX + 1) X 1.085 us where YYXX are TH, TL initial
values respectively.
Notice that values YYXX are in hex.
(b) in decimal
Convert YYXX values of the TH,TL register to decimal to get a
NNNNN decimal number,
then (65536 – NNNNN) x 1.085 mircosec
Timer Delay Calculation for XTAL = 11.0592
MHz

Timer

The 8051 uses two registers to handle and control the working of the
Timer registers. One of these registers is
TMOD. The other is TCON.
• TMOD (Timer mode register) – The timer registers can
operate in four different modes.
We’ll take a look at all these modes in a jiffy. But the point is,
the selection of the functioning
mode is done in this register. Additionally, the overall function
of the timer registers, whether
to work as timers or counters, is done here too.

• TCON (Timer Control Register) – At the risk of a slight


oversimplification that we will
address later, we only use half of the TCON register for timing
and counting purposes.
This register is used to initialize the counting and to indicate
when the timers have reached
their counting limit.

Timer modes in 8051 microcontrollers


Mode 0:
Mode 1:

Mode 2:

Mode 3:

RESULT:
Thus , the successfully verified.

You might also like