8051 microcontroller programming:Timers-interfacing Timer0 and Timer1 together
Timers are one of
the most important peripherals of 8051. There are two 16-bit counters present
in 8051.
It is controlled
using TMOD register.
G
|
C/T
|
M1
|
M0
|
G
|
C/T
|
M1
|
M0
|
The first four bits
are for the Timer1 and the lower four bits are for the Timer0.
G- Gate bit for
timer1.
0-TR1
should be made high starting the timer.
1-INT1
and TR1 should be HIGH for starting the timer.
C/T- Counter/Timer
0-Acts
as timer .i.e. internal oscillator provides the clock.
1-Acts as counter .i.e. external crystal provides the clock.
1-Acts as counter .i.e. external crystal provides the clock.
M1,M0- Mode
selectors.
M1
|
MO
|
MODE
|
FUNCTION
|
0
|
0
|
0
|
13-bit timer
|
0
|
1
|
1
|
16-bit timer
|
1
|
0
|
2
|
8-bit auto reload
timer
|
1
|
1
|
3
|
Split timer
|
Timer 1 in mode 2 is used for serial communication.
Maximum count possible is in Mode-1, that is FFFF (66535).
Delay(microseconds)=1.085*(Final value-Initial value+1)
The counter counts from the value given in TH and TL registers to the maximum value.
When the timer reaches the maximum value the TF bit goes high.
ORG 0000H SJMP MAIN ORG 000BH CPL P1.0 MOV TH0,#0A2H MOV TL0,#0AAH SETB TR0 RETI ORG 001BH CPL P1.1 MOV TH1,#01H MOV TL1,#22H SETB TR1 RETI MAIN: MOV IE,#8AH MOV TMOD,#11H MOV TH0,#32H MOV TL0,#0AAH MOV TH1,#01H MOV TL1,#22H SETB TR1 SETB TR0 SJMP $ END
titanium color | titanium color | titaniumart
ReplyDeleteThis ford escape titanium for sale is a titanium color titanium jewelry for playing casino games. These are all made with titanium teeth k9 titanium color. $4.95-each. 3 days ago. dewalt titanium drill bit set $2.95/each. 8 days titanium easy flux 125 ago.