Back to the 2020 paper

Module 6: Applications

20207m

What value should be loaded into timer register so as to have a time delay of 5 ms? Write a program to create a pulse width of 5 ms on pin P2.3. Assume crystal frequency to be 11.0592 MHz.

Worked SolutionAI Assisted

5 ms Delay Calculation & Program for P2.3 Pulse (11.0592 MHz)

Machine cycle: Fosc/12 = 11059200/12 = 921600 Hz → Tcy = 1.085 µs. Timer increments every 1.085 µs.
Counts needed for 5 ms = 5ms /1.085us = 4608 decimal = 1200H.
For 16-bit timer mode 1: TH:TL = 10000H - 1200H = EE00H. So TH=0EEH, TL=00H. For mode 1 with auto-reload? Use TL load accordingly. Alternative using 50 counts errors small.
If using Timer 0 mode 1:
TH0 = 0EEH, TL0 = 00H yields 5 ms.
For 5 ms high pulse on P2.3:

ORG 0000H
MAIN: MOV TMOD,#01H ; T0 mode1 16-bit
LOOP: SETB P2.3
      MOV TH0,#0EEH
      MOV TL0,#00H
      SETB TR0
WAIT: JNB TF0,WAIT
      CLR TR0
      CLR TF0
      CLR P2.3     ; after 5ms low (or keep high pulse 5ms)
      MOV TH0,#0EEH
      MOV TL0,#00H
      SETB TR0
WAIT2:JNB TF0,WAIT2
      CLR TR0
      CLR TF0
      SJMP LOOP
END

Alternative C: TH0=0xEE; TL0=0x00; loop. If using 12 MHz crystal, Tcy=1us, counts=5000=1388H, TH=0ECH, TL=78H.
Note: For exact 5ms pulse, set P2.3 high, delay, clear, delay.
If only delay value asked: 4608 counts → EE00H reload.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.