

PROGRAMMING STEPS OF THE COUNTER AND TIMER OF THE 8051 MICRO CONTROLLER :
1. Load the TMOD register indicating which timer is used and which MOD is to be selected.
2. Load TL & TH with initial count values.
3. Start the timer.
4. Keep monitoring the TF flag come out of the loop when TF = 1.
5. Stop the timer.
6. Clear the TF flag to continue the next counting.
7. Again reload TH & TL.
EXAMPLE PROGRAM:
MOV TMOD,#o1H
BACK: MOV TL0,#F2
MOV TH0,#FFH
CPL P1.0
LCALL DELAY
SJMP BACK
DELAY: SETB TR0
AGAIN: JNB TF0,AGAIN
CLR TRO
CLR TFO
RET
Recommended Questions
Useful Files
Users Joined





PROGRAMMING STEPS OF THE COUNTER AND TIMER OF THE 8051 MICRO CONTROLLER :
1. Load the TMOD register indicating which timer is used and which MOD is to be selected.
2. Load TL & TH with initial count values.
3. Start the timer.
4. Keep monitoring the TF flag come out of the loop when TF = 1.
5. Stop the timer.
6. Clear the TF flag to continue the next counting.
7. Again reload TH & TL.
EXAMPLE PROGRAM:
MOV TMOD,#o1H
BACK: MOV TL0,#F2
MOV TH0,#FFH
CPL P1.0
LCALL DELAY
SJMP BACK
DELAY: SETB TR0
AGAIN: JNB TF0,AGAIN
CLR TRO
CLR TFO
RET

