Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Timers
Description
SFR Address
TH0
Timer 0 High
Byte
8Ch
TL0
Timer 0 Low
Byte
8Ah
TH1
Timer 1 High
Byte
8Dh
TL1
Timer 1 Low
Byte
8Bh
TCON
Timer Control
88h
TMOD
Timer Mode
89h
Name
Explanation of Function
Timer
GATE1
When this bit is set the timer will only run when INT1
(P3.3) is high. When this bit is clear the timer will run
regardless of the state of INT1.
C/T1
T1M1
T1M0
GATE0
When this bit is set the timer will only run when INT0
(P3.2) is high. When this bit is clear the timer will run
regardless of the state of INT0.
C/T0
1
0
T0M1
T0M0
6
5
4
3
0
0
Timer Modes:
TxM1
TxM0
Timer Mode
Description of
Mode
13-bit Timer.
16-bit Timer
8-bit auto-reload
Name
TF1
TF0
TR0
Timer
8Fh
8Eh
8Dh
8Ch
TCON Timer
Control
Bit7
Bit6
Bit5
Bit4
TF1
Timer1
Flag
TR1
Timer1
On/Of
TF0
Timer0
Flag
TR0
Timer0
On/Of
Bit3
Bit2
Bit1
Bit0
Or
SETB TCON.4
CLR
TR0
Or
CLR
SETB
TF0
Or
SETB TCON.5
Or
CLR
CLR
TF0
TCON.4
TCON.5
Programming in C
#include <reg51.h>
void Delay (void);
sbit P1Bit5 = P1^5;
void main (void)
{
while (1)
{ P1Bit5 = ~ P1Bit5;
Delay ( );
}
}
//Timer0 Mode 1
TL0 = 0 x FF;
TH0 = 0 x 40;
TR0 = 1;
// Turn on Timer0
TR0 = 0;
TF0 = 0;