Fortune Telling Collection - Comprehensive fortune-telling - Calculation method of timer initial value of single chip microcomputer

Calculation method of timer initial value of single chip microcomputer

Ha ha, correct answer to you:

1 The time constant x of the timer can be calculated according to the calculation formula of the timing time:

Timing time t = (n -X power of 2) 12/ single chip microcomputer crystal frequency.

2 N is the working mode of the timer:

In mode 0, N= 13.

When the mode is 1, N= 16.

In mode 2, N=8.

3 according to the timing time and working mode, calculate the time constant x.

Convert x into a binary number, send the upper 8 bits to TH 1 and the lower 8 bits to TL 1, and you can start the timer to start counting.

For example: working in mode 1, timing time 1000 microseconds, crystal frequency = 12MHZ.

Then the timing time t = (power of 2 16-x)12/12mhz =1000 gives X=64536=FC 18H.

Hehe, if you are satisfied, please choose the satisfactory answer.