All Exams Test series for 1 year @ ₹349 only
Question

Find the delay generated by Timer 0 in the following code of 8051 microcontroller : clock period = 1.085 µs.

MOV TMOD, #01H

MOV TLO, #3DH

MOV THO, #0A2H.

 

SET B TRO

Loop : J N B TFO, LOOP

CLR TRO

CLR TFO

This question was previously asked in
UGC NET 2023 Paper 1 Question Paper (22-Jun-2023) (Shift 2)
The correct answer is

26.043 ms

Read the code.

\(\texttt{MOV TMOD,\#01H}\) — the low nibble configures Timer 0; 0001 selects Mode 1, the 16-bit timer mode (GATE = 0, C/T = 0, so it is a timer clocked internally, started purely by software).

\(\texttt{MOV TL0,\#3DH}\ /\ \texttt{MOV TH0,\#A2H}\) — load the initial count. \(\texttt{SETB TR0}\) starts it; the JNB TF0, LOOP line simply spins until the overflow flag is set; CLR TR0 stops the timer.

How an 8051 timer measures a delay. The timer counts up from the loaded value, one increment per machine cycle, and sets the overflow flag TF0 when it rolls over from FFFFH to 0000H. So the number of counts is the distance from the loaded value to 65536.

Step 1 — form the 16-bit initial value. TH0 is the high byte, TL0 the low byte:

\(TH0{:}TL0 = A23D_{16}\)

Step 2 — convert to decimal.

\(A23D_{16} = (162 \times 256) + 61 = 41472 + 61 = 41533\)

Step 3 — counts to overflow.

\(N = 65536 - 41533 = 24003\ \text{counts}\)

Step 4 — multiply by the machine-cycle time. One count = one machine cycle = 1.085 µs (this corresponds to the usual 11.0592 MHz crystal, since 12/11.0592 MHz = 1.085 µs):

\(t = 24003 \times 1.085\ \mu s = 26043.3\ \mu s\)

\(t = 26.043\ \text{ms}\)

Shortcut for such problems. Counts = 65536 − (TH:TL); an equivalent trick is to take the 2's complement of the loaded value, i.e. \(FFFF_{16}-A23D_{16}+1 = 5DC3_{16} = 24003\). To design for a desired delay you invert the procedure: divide the delay by 1.085 µs, subtract from 65536, and load the hexadecimal result. Mode 1's longest single delay is \(65536 \times 1.085\ \mu s \approx 71.1\ \text{ms}\), so longer delays need a repeat loop.

Hence, the delay generated by Timer 0 is 26.043 ms.

Was this answer helpful?

Similar Questions

  1. Given below are two statements :

    Statement I : In 8051 micro-controller register banks and stack reserves 32 bytes from locations 00 to 1F Hex

    Statement II : Bit-Addressable RAM locations are 20 H to 2 F H.

    In the light of the above statements, choose the most appropriate answer from the options given below :

  2. In "JZ Next" instruction of 8051 microcontroller, which register's content is checked to see if it is zero?

  3. Using 8051 assembly language programming numbers 54 H and 98 H are added. After addition the status of CY, AC and P flags are respectively:

  4. In 8051 microcontroller, one machine cycle lasts in 12 oscillation period. Crystal oscillator's frequency is 11.0592 MHz. Find how long it takes to execute instruction MOV R4, # 25.

  5. Advantage of segmented memory in 8086 is

    A. Allows the memory capacity to be 1M byte, although the actual address is of 16 bit size.

    B. Allows the placing of code and data portions of the same program in different parts of memory.

    C. Allows the memory capacity to be 2M byte, although the actual address is of 16 bit size.

    D. Allows the placing of code and data portion of the same program in same parts of memory.

    E. Allows the memory capacity to be 1M byte, although the actual address is of 20 bit size

    Choose the correct answer from the options given below :

  6. Which of the following statements are correct for a microcontroller ?

    A. A microcontroller has on-chip I/O ports

    B. A microcontroller has a fixed amount of RAM on the chip

    C. The flag register in the 8051 is called program standard word

    D. Auxiliary carry flag is set when there is a carry from D3 to D4 during an ADD or SUB operation

    E. Overflow flag is only used to detect errors in unsigned arithmetic operations.

    Choose the correct answer from the options given below :

  7. Match List I with List II

    LIST I (instruction of 8051 microcontroller)LIST II (Addressing mode)
    A.MOV A, # 32 HI.Register addressing mode
    B.MOV R 6, AII.Register Indirect addressing mode
    C.MOV R4, 7 FHIII.Immediate Addressing mode
    D.MOV A, @ ROIV.Direct Addresing mode

    Choose the correct answer from the options given below:

  8. The ALE line of an 8085 microprocessor is used to

  9. Contents of ‘A’ register after execution of the following 8085 microprocessor program is

    MVI A, 55 h

    MVI C, 25 h

    ADD C

    DAA

  10. Word 20 contains 40

    Word 30 contains 50

    Word 40 contains 60

    Word 50 contains 70

    Which of the following instructions loads 60 into the accumulator ?

    (a) load immediate 60

    (b) load direct 30

    (c) load indirect 20

    (d) load indirect 30

    Which of the above statements are correct ?


Important Questions from Microprocessors

  1. Register which is used to store values of arithmetic and logical operations is termed:

  2. How many bytes of bit addressable memory is present in 8051 based microcontrollers?

  3. A single instruction to clear the lower four bits of the accumulator in 8085 assembly language is-

  4. In Microprocessor 8085 Address/Data buffer is a/an _______ buffer.

  5. Microprocessor 8085 operates on a clock cycle with ______ duty cycle.

Need Expert Advice?
Test Series
UGC NET img
Teaching
UGC NET Library and Information Science 2024 - 2025 Mock Test Series
66 Tests 4 Tests Free
791 Attempts
4.4(17)
English, Hindi

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App