To control timer
operation two special Functions Register are used
1.
TCON (Timer Control Register)
2.
TMOD (Timer Mode Selection Register)
TCON register
TCON is an 8-bit register, which controls the
timer1 and timer0.
Bits and functions of every bits of TCON are as
follows:
BIT
|
Function
|
TF1 / TF0
|
·
Timer 1 / Timer 0 overflow.
·
This bit is set (i.e. TF1=1
/ TF0=1) by the microcontroller when timer1 / timer0 overflows.
|
TR1 / TR0
|
·
Timer 1 / Timer 0 run.
· When this bit is set (i.e.
TR1=1 / TR0=1) Timer1 / Timer0
is turn on.
· When this bit is reset
(i.e. TR1=0 / TR0=0) Timer1 / Timer0
is off.
|
IE1 / IE0
|
·
External interrupt (
·
This bit is set (i.e. IE1=1
/ IE0=1) when external interrupt (
|
IT1 / IT0
|
·
External interrupt (
·
This bit is set (i.e. IT1=1
/ IT0=1) when external interrupt (
·
This bit is clear (i.e. IT1=0
/ IT0=0) when external interrupt (
|
TMOD (Timer Mode)
Register
Both Timer 0 and Timer 1 use the same register to
set the various timer operation modes. It is an 8-bit register in which the
lower 4 bits are set aside for Timer 0 and the upper four bits for Timer 1.
BIT
|
Function
|
||||||||||||||||||||
Gate
|
· Timer1 / Timer0 control.
Every timer has a means of starting and stopping. Timers do this by software or hardware.
· This bit is reset
(i.e. Gate=0) when timer 1 /
timer 0 controlled by software.
It means when this bit is reset, timer1 / timer0 will start when
TR1 / TR0 bit of TCON is set.
· This bit is set (i.e. Gate=1) when timer 1 / timer 0 controlled
by hardware.
It means when this bit is set, timer1 / timer0 will start after
arriving of external interrupt (
|
||||||||||||||||||||
|
· Timer or Counter
selector.
· When this bit is reset
(i.e.
·
When this bit is set (i.e.
|
||||||||||||||||||||
M1 & M0
|
|
No comments:
Post a Comment