Traditional Culture Encyclopedia - Photography and portraiture - How to set the timer of 5 1 single chip microcomputer?

How to set the timer of 5 1 single chip microcomputer?

The setting steps of the microcontroller timer are as follows:

1. Set the working mode of the timer. There are four working modes and two modes (counter/timer). For example:

MOV TMOD,# 0 1; Set the timer 0-bit timer mode, and the working mode is 1.

2. Assign an initial value according to the timing time. For example, the timing is 10 millisecond, so if the crystal oscillator is 12M, it is 10000 machine cycles. The timer is an overflow application interrupt, so the initial value is the overflow value minus the timing period.

MOV TH0 # high (65536- 10000)

MOV TL0 # low (65536- 10000)

3. Start the interrupt and timer.

SETB ET0

SETB Electronic Arts Circle

SETB TR0