Search this site

8051 Timer Programming in Assembly and C - Unit 9 - Review Questions & Answers from 8051 Microcontrollers & Embedded Systems by Mazidi

 SECTION 9.1: PROGRAMMING 8051 TIMERS

1. How many timers do we have in the 8051?

2. Each timer has _______ registers that are ______ bits wide. 

3. TMOD register is a(n) ______ bit register.

4. True or false. The TMOD register is a bit-addressable register.

5. Indicate the selection made in the instruction "MOV TMOD, #20H". 

6. In mode 1, the counter rolls over when it goes from ______ to ______

7. In mode 2, the counter rolls over when it goes from _______ to ________

8. In the instruction "MOV THl, #-200", find the hex value for the TH register.

9. To get a 2-ms delay, what number should be loaded into TH, TL using mode 1? Assume that XTAL = 11.0592 MHz. 

10. To get a 100-µs delay, what number should be loaded into the TH register using mode 2? Assume XTAL = 11.0592 MHz. 

Answers: 

1. Two 

2. 2, 8 

3. 8 

4. False

5. 0010 0000 indicates Timer 1, mode 2, software start and stop, and using XTAL for frequency. 

6. FFFFH to 0000

7. FFH to 00

8. -200 is 38H; therefore, THl = 38H 

9. 2 ms/1.085 ms= 1843 = 0733H where TH= 07H and TL= 33H

10. 100 ms/1.085 ms= 92 or 5CH; therefore, TH= 5CH 


SECTION 9.2: COUNTER PROGRAMMING 

1. Who provides the clock pulses to 8051 timers if C/T = 0?

2. Who provides the clock pulses to 8051 timers if C/T = 1? 

3. Does the discussion in Section 9.1 apply to timers if C/T= 1?

4. What must be done to allow P3.4 to be used as an input for Tl, and why? 

5. What is the equivalent of the following instruction? "SETB TCON. 6" 

Answers: 

1. The crystal attached to the 8051 

2. The clock source for the timers comes from pins TO and Tl. 

3. Yes 

4. We must use the instruction "SETB P3. 4" to configure the Tl pin as input, which allows the clocks to come from an external source. This is because all ports are configured as output upon reset. 

5. SETB TRl 


SECTION 9.3: PROGRAMMING TIMERS 0 AND 1 IN 8051 C

1. Who provides the clock pulses to 8051 timers if C/T = O?

2. Indicate the selection made in the statement "TMOD = Ox20". 

3. In mode 1, the counter rolls over when it goes from _____ to ___________

4. In mode 2, the counter rolls over when it goes from ______ to ________ 

5. In the statement "THl = -200", find the hex value for the TH register.

6. TFO and TFl are part of register ____________ 

7. In Question 6, is the register bit-addressable?

8. Show how to monitor the TFl flag for high in 8051 C. 

Answers: 

1. The crystal attached to the 8051 

2. Timer 2, mode 2, 8-bit auto reload 

3. FFFFH to O 

4. FFH to O 

5. 38H 

6. TMOD 

7. Yes

8. while (TF1==0);



No comments:

Post a Comment