Question

In: Electrical Engineering

Referring 8051 User’s Manual ,study how to use timer when operating in mode 2. Understand the...

Referring 8051 User’s Manual ,study how to use timer when operating in mode 2.

Understand the manual (p. 112~)

Solutions

Expert Solution

Mode 2 Programming

Mode 2 programming mode is an 8 bit auto reload mode

1. Mode 2 is an 8 bit timer. This means that the timers register TH can be loaded with values from 00 to FFH.

2. As soon as TH is loaded, a copy of the same is is given to TL.

3. Now the timer has to be started. This is done by SETB TR0 or SETB TR1 based on which timer is selected.

4. Now that the timer is started, it starts to count up by incrementing the TL register. It counts till it reaches FFH. When it reaches FFH, it will roll over to 00H, and sets the timer flag high(TF).

5. When TL register rolls from FFH too 00 and the timer flag is set, TL is automatically reloaded with the original value kept in TH register. To repeat the process, we must simply clear the TF. We need not reload the original value. This is why it is called an auto reload mode.

Steps to Program in Mode 2

Suppose, we want to generate a time delay using timer's mode 2, we have to do the following steps.

Step1: Load the TMOD value register indicating which timer is to be used, either Timer 0 or Timer 1, and select TIMER mode as 2.

Step2: Load TH register with the initial count value

Step 3: Start the timer by using SETB TR0 or SETB TR1 depending on which timer you have selected.

Step 4: Keep monitoring the timer flag(TF) using the instruction JNB TF0, ADDRESS or JNB TF1, ADDRESS depending on the timer selected. This is to see whether the count has rolled over from FFH to 00.

Step 5: Clear the TF flag. This is done by the instruction CLR TF0 or CLR TF1 depending on the timer that you have selected.

Step 6. Go back to step 4.

Example:

This program just creates square wave at port P3.3

MOV TMOD, #20H           ; Timer 1, Mode 2 (8 bit auto – reload)
MOV TH1, #00H ; Initial Value loaded
          
AGAIN: CPL P3.3 ; Complement the port pin 3.3
SETB TR1 ; Start Timer 1
HERE: JNB TF1, HERE ; Wait for the roll over from FFH to 00

CLR TF1 ; Clear Timer Flag
SJMP AGAIN ; Repeat
          


Now the code is burned to the 8051 in Proteus and the waveform is observed at P3.3

Mode 2 is usually used in Serial Communication


Related Solutions

Study how to use D/A converter regarding DAC0800 Manual (answer typed please) Understand the manual
Study how to use D/A converter regarding DAC0800 Manual (answer typed please) Understand the manual
1 why is it important for students in accounting to understand how to use a manual,...
1 why is it important for students in accounting to understand how to use a manual, paper based accounting system when most accounting systems are electronic today? 2- why are there so many different accounting information systems software packages ? 3- in your opinion, what area of accounting needa computerized accounting software the most? payroll? tax? auditing? something else? 4- forensic means " suitable for use in a court of law." how does that have anything to do with accounting?...
Questions from Ch 2 of 9780763865061. I understand there is no solution manual for that Quickbooks...
Questions from Ch 2 of 9780763865061. I understand there is no solution manual for that Quickbooks textbook. Please confirm the following is correct. Vendor—someone from whom the business buys goods or services Vendor center—contains a file for all vendors with whom the company does business Unpaid Bills report—a report that lists all unpaid vendor bills at a specific date Credit memo—processed through the Enter Bills window to reflect a reduction of the vendor’s liability due to a credit for return...
When economists use the term "big tradeoff" when discussing efficiency they are referring to the tradeoff...
When economists use the term "big tradeoff" when discussing efficiency they are referring to the tradeoff between producer surplus and consumer surplus. efficiency and fairness. deadweight loss and producer/consumer surplus. marginal cost and marginal benefits. external costs and external benefits. Imposing a sales tax on sellers of a product has an effect that is similar to which of the following? anything that decreases the demand and shifts the demand curve leftward an increase in demand for the good a decrease...
. Typically when astronomers use the term flux, they are referring to an energy flux, or...
. Typically when astronomers use the term flux, they are referring to an energy flux, or the amount of energy flowing through an area (typically, spherical) in unit time. This is the same flux we refer to when we calculate luminosity from flux and distance. Assuming that flux is due solely to photons, derive an expression for themomentum flux of the photons.
How do you understand and interpret mean, median, mode, standard deviation, and variance?
How do you understand and interpret mean, median, mode, standard deviation, and variance?
When is it best to use the mode as a measure of center? Describe what type...
When is it best to use the mode as a measure of center? Describe what type of data would lead you to choosing the mode over the mean or median. If a set of numbers has a standard deviation of zero, what can you say about the numbers? If a set of grades for a class has a large range and a small standard deviation, what can you say about the class? Include an interpretation that is specific to grades...
you will write 2 reports (referring to the departments of Dermatology and Cardiology) and use them...
you will write 2 reports (referring to the departments of Dermatology and Cardiology) and use them as your script for your Week 3 Oral Report. Your writing section for this assignment will include 2 paragraphs for each department. In order to earn the maximum credit for the written report you need to incorporate at least 10 medical terms for each department (a total of 20 terms for this assignment), using them in a manner that demonstrates your knowledge of their...
i)How should you use operating costs when calculating incremental cash flows? a) Do not subtract operating...
i)How should you use operating costs when calculating incremental cash flows? a) Do not subtract operating costs, and then subtract taxes on operating income before operating costs. b)Subtract operating costs, calculate taxes off of that number, and then add them back. c)Subtract taxes as though operating costs were not tax-deductible. Then subtract operating costs. d) Subtract operating costs. ii) At the end of a project, the equipment purchased at the beginning is expected to have a positive market value that...
We want to conduct marketing/market research...what will be type of interview..understand when to use, how, and...
We want to conduct marketing/market research...what will be type of interview..understand when to use, how, and advantages and disadvantages + kind of capabilities you should have as interviewer (questions types/guide/criteria for successful interviewer) Be familiar with questionnaire survey (Go to library and check it out) You have to design simple one according to certain requirements (include demographic questions / 3 key variables/ 3 indicators per one variable )
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT