Single chip microcomputer in the timing/counter can have a variety of purposes, to pass the timing/counter control Word to set, the need for use.
In the microcontroller, there are two special function registers related to timing/counting, this is tmod and Tcon. , Tmod and Tcon are names, we can specify them directly with this name when we write the program, and of course we can specify them directly with their addresses 89H and 88H (in fact, using the name is directly with the address, the Assembly software to help you translate it).
The Tmod is divided into two parts, 4 bits per part. Used to control T1 and T0 respectively. The Tcon is also divided into two parts, the high 4 bits for the timer/counter, and the lower 4 bits for interrupts (TF1, 0 in this). TR0 (1) called the Run control bit, 1, the switch to close, counting pulses to come over, can be used instruction Setb and the CLR to set a bit to start/close counters/timers.
Mode 0 Block Diagram
timed
/
four ways to work with counters
Mode 0
is a 13-bit counter consisting of the low 5 bits of the TL (1/0) and the 8 bits of th (0/1), at which point the high 1/0 bits of the TL (3) are not used.
M1, M0: Timing/Counter A total of four ways of working, is controlled by the M1M0, 2 bits is exactly four combinations.
c/t:c/t 0 is used as a timer (switch up), if c/t is 1 is used as a counter (switch down).
Gate:gate after the door is one or the door, gate=0 as long as the tr1=0 switch closed
Gate=1, the switch closed not only by the TR1, but also by the INT1 pin control, two are high-level counting pulses to pass.
Mode 1
Mode of Operation 1 is a 16-bit timing/counting mode, the M1, M0 set to 01, the other features and working mode 0 is the same.
Mode 2
How the preset number is automatically loaded. When overflow, the switch between the T (0/1) high and low eight bits is turned on, placing the preset number in the high eight bits into the lower eight bits, starting the second round, which is done by the hardware. The price is half the count range.
Mode 3
The timer/counter is split into 2 separate timer/counter to be used.
(The bottom is TR1)
The TL0 can form a 8-bit timer or counter, while the TH0 can only be used as a timer.
TLo uses the T0 state control bits c/t, GATE, TR0, INT0, and TH0 uses T1 state control bit TR1, generally only T1 in mode 2 (when the baud rate generator), in order to let T0 work in mode 3.
Timer
/
timing of the counter
/
Count Range
Mode of operation 0:13 bit timing/counting method, therefore, up to 2 of the 13, that is, 8,192 times.
Mode of Operation 1:16-bit timing/counting method, so the maximum can be counted to 2 16, that is 65,536 times.
Mode 2 and mode of Operation 3, are 8-bit timing/counting method, so the maximum can be counted to 2 8 times, also said 256 times.
Preset value calculation: Subtract the required number of counts by the maximum amount.
Single chip microcomputer timing/counting mode of operation