1. The structure of timer / counter is shown in Figure 1.

Analysis of the basic structure and working principle of timer and counter of 51 single chip microcomputer

Picture 1

2. Timer / counter mode control register tmod

Tmod is used to control the working mode of timer / juice counter. Its byte address is 80h and the format is as follows. Among them, the lower four bits are used to determine the operation mode of T0, and the higher four bits are used to determine the operation mode of T1.

Analysis of the basic structure and working principle of timer and counter of 51 single chip microcomputer

Picture 1

1) , M1 and M0 working mode control bit

M0 and M1 are control bits of working mode, and four working modes are determined, as shown in Table 1.

Analysis of the basic structure and working principle of timer and counter of 51 single chip microcomputer

Picture 1

2) , C / T timer / counter mode selection bit

C / T = 0, set to timing mode, count the machine cycle;

C / T = 1, set to count mode, count external signal, external signal connected to t0 (p3.4) or T1 (p3.5) pin.

3) Gate gate control position

When gate = 0, the timer T0 (or T1) can be started as long as tr0 (or Tr1) is set to 1 by software;

When gate = 1, the timer T0 (or T1) can be started only when the INT0 (or INT1) pin is at high level and tr0 (or Tr1) is set to 1 by software.

Source; 21ic

Leave a Reply

Your email address will not be published. Required fields are marked *