INTRODUCTION:-
- In 8051, 2 timers are there i.e T0, T1. These timer are 16 bit registers
- The timer puls run at 1/12th clock cycle.
- The clock frequency for serial communication is 11.0592 M Hz
- So a single machine cycle run "1" instruction the timing is =1.0892 us i.e {12/11.0592 M Hz}
APPLICATION:-
- Generate a delay
- Event Counter
- Baud rate for serial communication
- Timers can be used as a timer as well as counter but not at a time
- each timer is a 16 bit wide
- Each timer can split two equal parts i.e TL{0/1} and TH{0/1}
15
|
14
|
13
|
12
|
11
|
10
|
9
|
8
|
7
|
6
|
5
|
4
|
3
|
2
|
1
|
0
|
<----------------TH0------------------------------------> <-------------------------TL0------------------------>
FOR T1:
15
|
14
|
13
|
12
|
11
|
10
|
9
|
8
|
7
|
6
|
5
|
4
|
3
|
2
|
1
|
0
|
<----------------TH0------------------------------------> <-------------------------TL0------------------------>
Timer registers:-
- In 8051, six timer registers are there
- TMOD Register
- TCON Register
- TH0
- TL0
- TH1
- TL1
TMOD REGISTER:-
- TMOD Register is a 8 bit register.
- Which is a Byte addressable register.
- This register is used for timer mode section , timer start by what and finally timer or counter selection either timer 0 or timer 1
i.e We should n't set bit by bit in this register
7
G
|
6
C/T
|
5
M1
|
4
M0
|
3
G
|
2
C/T
|
1
M1
|
0
M0
|
<--------------TIMER1---------------------------> <------------TIMER0---------------------------->
GATE (G);-
- If G=0, Then Timer start by software / Program
- If G=1, Then Timer start by Hardware / External
COUNTER / TIMER (C/T);-
- If (C/T)=0 , i.e Timer will be selected
- If (C/T)=1, i.e Counter will be selected
MODE SELECTION BITS (M1,M0):-
M1
|
M0
|
MODE
|
SELECTION
|
0
|
0
|
0
|
13 BIT TIMER
|
0
|
1
|
1
|
FULL 16 BIT TIMER
|
1
|
0
|
2
|
8 BIT AUTO RELOAD TIMER
|
1
|
1
|
3
|
SPLIT TIMER
|
TCON:-
- Timer Control register is 8 bit register.
- It is bit addressable register. i.e we can change bit by bit
- Timer control register is used to control the timer i.e we can start and stop by using this register
- TIMER OVER FLOW FLAG [TF]:-
This TIMER OVER FLOW SET by hardware i.e TF=1 When the timer gets overflow.
FOR TIMER0:-
TF0=1
FOR TIMER1:-
TF1=1
This TIMER OVERFLOW FLAG is CLEAR by software, when the timer is overflow.
FOR TIMER0:-
TF0=0
FOR TIMER1:-
TF1=0
- TIMER CONTROL BIT [ TR ]:-
If TR bit is SET then the timer will start.
FOR TIMER0:-
TR0=1
FOR TIMER1:-
TR1=1
If TR bit is CLEAR then the timer will stop.
FOR TIMER0:-
TR0=0
FOR TIMER1:-
TR1=0
- EXTERNAL INTERRUPT [ IE ]:-
External interrupt edge flag is set / clear by hardware when interrupt is processed.
- TIMER INTERRUPT [ IT ]:-
These are timer interrupt flags. These bare SET for negative edge trigger/ CLEAR for level trigger
No comments:
Post a Comment