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?...
Timer 0 in normal mode (AVR) MSYS LAB8 I'm lost on how to write this.. #include...
Timer 0 in normal mode (AVR) MSYS LAB8 I'm lost on how to write this.. #include <avr/io.h> #include "led.h" // Prototype void T0Delay(); int main() {    unsigned char x = 0;    //Ready the LED-port    initLEDport();        DDRA = 0x00; //port A as input        DDRB = 0xFF; //port B as output    while(1)    {        // Wait 1/125 seconds        T0Delay();        // Increment and show the variable x       ...
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.
"Why must you read and understand your pharmacy's P & P manual when you start your...
"Why must you read and understand your pharmacy's P & P manual when you start your new pharmacy technician job? How does the manual impact your new job?"
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...
When an interrupt occurs while operating in User mode, present the rWhen an interrupt occurs while...
When an interrupt occurs while operating in User mode, present the rWhen an interrupt occurs while operating in User mode, present the return instruction of the exception handler and describe the reason for such a 3 stage pipeline structure
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT