Interrupt number
interrupt 0 External interrupt 0 (EX0) interrupt 1 Timer /timer interrupt 0 (ET0) interrupt 2 External interrupt 1 (EX1) interrupt 3 Timer/timer interrupt 1 (ET1) interrupt 4 Serial port interrupt (ES ) Timer working mode 1. Mode 0 consists of 8 bits of TH0 and the lower 5 bits of TL0 to form a 13-bit timer. When the 13-bit timer is from 0 or the set value, after adding 1 to all '1', adding 1 will cause overflow. At this time, the TF0 bit of TCON is set to 1, and the timer is initialized to all '0' at the same time . 2. Mode 1 Mode 1 and Mode 0 work the same, the only difference is that TH0 and TL0 form a 16-bit counter. The reset method is the same as that of method 0. 3. Method 2
Configure TL0 as an 8-bit timer that can automatically restore the initial value (the initial constant is automatically reloaded)
, TH0 is used as a constant buffer, and TH0 is preset by software. When TL0 overflows, on the one hand, the
overflow flag is set. 1. At the same time, reload the 8-bit data in TH0 into TL0.
Mode 2 is often used for timing control. For example, if you want to generate a timing control pulse every 250us,
you can use a 12MHz oscillator, preset TH0 to 6, and make C/=0 to achieve it. Mode 2
is not used as a serial port. baud rate generator.
4. Mode 3
Mode 3 is different for timer T0 and timer T1.
If T1 is set to mode 3, it will stop working (the effect is the same as TR1=0),
so mode 3 is only applicable to T0
Configure TL0 as an 8-bit timer that can automatically restore the initial value (the initial constant is automatically reloaded)
, TH0 is used as a constant buffer, and TH0 is preset by software. When TL0 overflows, on the one hand, the
overflow flag is set. 1. At the same time, reload the 8-bit data in TH0 into TL0.
Mode 2 is often used for timing control. For example, if you want to generate a timing control pulse every 250us,
you can use a 12MHz oscillator, preset TH0 to 6, and make C/=0 to achieve it. Mode 2
is not used as a serial port. baud rate generator.
4. Mode 3
Mode 3 is different for timer T0 and timer T1.
If T1 is set to mode 3, it will stop working (the effect is the same as TR1=0),
so mode 3 is only applicable to T0