[Turn]51 single-chip microcomputer 11.0592MHz generated 115200 baud rate

Source: Internet
Author: User

Connection: http://homezzy.blog.hexun.com/29601793_d.htmltoday solved a small problem (check the book before you get the exact conclusion ...) ) with 51 single-chip microcomputer+ One. 0592 Crystal Oscillator, how to generate 115200 baud rate? Originally felt this meaning, direct initialization timer 1, the program is as follows:voidInit_com (void) {SCON=0x50;//serial port operating mode 1, 8-bit UART, baud rate variableTmod |=0x20;//Timer 1, working mode 2, automatically reload 8-bit timerPCON |=0x80;//smod=1; double the baud rate.TH1 =0XFA;//baud rate: 9600 crystal oscillator =11.0592mhzIE |=0x90;//enable the serial port to interruptTR1 =1;//Timer 1 Startthe results found that this can only get 9600 baud rate ... When Smod=1, k=2, the baud rate doubles, the formula is: Baud rate=kx11059200/ +X AX ( the-TH1) So, TH1=0XFA= the-(2X11059200/384x baud rate) where the baud rate is 9600 at this time, timely make TH1=0xFF, the maximum baud rate can only be 57600, that is, this can not get 115200 baud rate ... This is the only way to use the other methods:1, crystal oscillator, with 22.1184M crystal oscillator, in th1=at 0xFF, a 115200 baud rate can be generated. 2, the use of 6 clock cycle of single-chip microcomputer (SCM AH ... )3, enhanced 51 single-chip microcomputer has timer 2! (Fortunately, I use the enhanced type ...) It's a third way! At this point the formula is as follows: Baud rate=11059200/ +x[65535-(RCAP2H,RCAP2L)] where the rcap2h,rcap2l is the automatic reload value, from the above: rcap2h,rcap2l=65536-11059200/ +x baud rate is 115200 when the baud rate is rcap2h,rcap2l=0xFF,0xfd, the initialization program is as follows:voidInit_com (void) {SCON=0x50;//serial port operating mode 1, 8-bit UART, baud rate variableTh2=0xFF; TL2=0xFD;//baud rate: 115200 crystal oscillator =11.0592mhzRcap2h=0xFF; RCAP2L=0xFD;//16-bit auto Reload value/*****************/TCLK=1; RCLK=1; C_t2=0; EXEN2=0;//baud Rate Generator working mode/*****************/TR2=1;//Timer 2 Start}ok! This is achieved with 51 single-chip microcomputer + One.0592 Crystal Oscillator, the production of 115200 baud rate, of course, the veteran looks very basic, but a long time no, and then review ~ ~

[Turn]51 single-chip microcomputer 11.0592MHz generated 115200 baud rate

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.