Calculation of timer, baud rate, th and TL values

Source: Internet
Author: User

Assuming the crystal oscillator bit 6MHZ, timing 10ms

SCM System Crystal frequency of 6MHz, the system Clock frequency (also the timing pulse frequency ) is 500KHZ, a pulse period of 2us, 10ms is 5,000 pulses, so
tmod=0x01;
th0= (65536-5000)/256;
tl0= (65536-5000)%256;

Mode 0:13 bit timing counting method, the maximum count value is 2^13=8192, timing 8,192 machine cycle . This method is no longer used, is to be compatible with the previous microcontroller, the beginning of the study do not have to master.
Mode 1:16-bit timing counting method, the maximum count value is 2^16=65536, timing 65,536 machine cycle . This way, the maximum timing time and maximum count times can be achieved. is one of the most common ways.
Mode 2:8-bit automatic reload count mode, the maximum count value is 2^8=256, timing 256 machine cycle . This mode of operation is timed or counted to a high precision without reloading the initial value. In addition, the serial communication is often used in this way. is one of the most common ways.
Mode 3: Special mode of operation. The timer 0 is divided into two 8-bit functions of the timer counter, to occupy the T1 part of the function. Also not used.

Calculation of timer, baud rate, th and TL values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.