Lab#09 LAB NAME: Counters in 8051
Lab#09 LAB NAME: Counters in 8051
Lab#09
LAB NAME: Counters In 8051
9.1 Lab 0bjective: To become familiar with counters how they are used in 8051
9.2 Pre lab reading:
Book: the 8051 microcontroller and embedded systems, edition second, author Muhammad
Ali mazidi, chapter 09, and topic: delay program
9.3 Equipment:
Proteus 8, power supply
9.4 Components:
8051 microcontroller, led, wires,
9.5 Circuit:
9.6 Code:
ORG 00H
main:
MOV TMOD, #60H
MOV TH1,#0H
SETB P3.5
AGAIN: SETB TR1
HERE: MOV A,TL1
MOV P2, A
JNB TF1, HERE
1
21395
Microcontroller and Microprocessor lab 9
CLR TF0
SJMP AGAIN
End
9.7 Output:
9.8 Exercise/procedure:
Open the software for the simulation. Go for the new project and select the controller. Now
write the program for timer in assembly. 8051 has two timer (timer0.timer) but here we used
timer0 for our simulation. But here we have used counter instead of timer. Counter0 is used
for the counter operation. After completing the code and circuit now check the errors if any
then fix it and run it
Mod0 is of 13-bit and mod1 is of 16-bit and the mod2 is 8-bit auto reload.
Code the counter0 for mod0 run the simulation and observe the result. Repeat the procedure
for mod1 and mod2.
9.9 Notes:
We can use timers 0 and 1 as event counters. A timer can be used as a counter if we provide
pulses from outside the chip instead of using the frequency of the crystal oscillator as the
clock source. By feeding pulses to the TO (P3.4) and Tl (P3.5) pins, we turn Timer 0 and
Timer 1 into counter 0 and counter 1.
2
21395
Microcontroller and Microprocessor lab 9
1-counters in 8051
Problem Number 2-using counter for event
count
Working
Lab Performance
Viva
Instructor's Verification
3
21395