The maximum timing time of timer T0 is ( ). A. 32.767s B. 327.6

The correct answer is: C

The 51 microcontroller has two timers for interrupt counting, namely T0 and T1. The timers of the 52 MCU and the 51 MCU are the same, except that the 52 has one more timer/counter T2 than the 51. Their settings are similar. Let me summarize the usage of each timer.

The difference between timer T0 and T1 is that their working mode 3 is different, and modes 0, 1, and 2 are the same.

M1

M0

Working mode

Mode 0, 13-bit timer/counter

1

Mode 1, 16-bit timer/counter

1

Mode 2, 8-bit timer/counter with automatic reloading

1

1

Method 3, only applicable to T0, divided into two 8-bit counters,

Stop counting when set to T1

First we look at what should be set to use timer T0:

1. Initialize the interrupt register and timer:

Initialization The content in the function can also be written in the header file, but for the sake of beauty and easy reference, write it out separately, and then call it directly in the header file. Then you should make initial settings:

①Set the working mode of the timer

In the microcontroller, there is a special register called TMOD, which is used to set the working mode of the timer. Register, through software, set the D0~D7 bits in the register to 0 or 1 to achieve the operation of the timer.

Register TMOD

Timer 1

Timer 0

Bit number

D7

D6

D5

D4

D3

D2

D1

D0

Bit symbol

GATE

C/?

M1

M0

GATE

C/?

M1

M0

As shown in the table, this is the timer working mode register TMOD. To change the working mode of the timer, we only use M1 and M2, so the other bits are generally set to 0, and because we are using the T0 timer, we have:

0000 0000

Use working mode 0

0000 0001

Use working mode 1

0000 0010

Use working mode 2

0000 0011

Use working mode 3

Control M1 and M0 and set them to 1 or 0 to achieve the purpose of the operation control mode, and then convert it to hexadecimal. Easy to read.

Similarly, the same setting is used when using timer 1. Note that sometimes two timers T0 and T1 are used, so both 0001 and 0001 are working mode 1.