1. The complete code is as follows: C
#include#define uchar unsigned char
#define uint unsigned int
void send(uchar state)
{
SBUF=state;
while(TI==0);
TI=0;
}
void SCON_init(void)
{
TMOD=0x20;//6T mode, 11.05992@115200
SCON=0x50;
PCON=0x80;
TL1=0xFF;
TH1=0xFF;
TR1=1;
/*SCON=0x50;//Timer 2 mode, 11.0592@115200
TH2=0xFF;
TL2=0xFD;
RCAP2H=0xFF;
RCAP2L=0xFD;
TCLK=1;
RCLK=1;
C_T2=0;
EXEN2=0;
TR2=1;*/
}
void main()
{
SCON_init();
while(1)
{
send('A');
}
}
2. Remarks
The "SCON_init" subroutine is a subroutine for serial port baud rate setting and initialization. It can be called once at the beginning of the main program. In the entire serial port baud rate initialization subroutine, the complete codes of our two methods are in it. The code that is not marked with comment symbols is the code for 6T mode, and the code that is marked with comment symbols is implemented through timer 2 in 12T mode. code.
The setting of 6T or 12T mode is selected by yourself when programming the program, and no code setting is required. Timer 2 is only available in enhanced 51 microcontrollers such as STC89C52RC.
Previous article:Design of eight-way voltmeter using AT89C52 microcontroller
Next article:How to use STC89C52 microcontroller to make a multiple signal generator
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- USB Type-C® and USB Power Delivery: Designed for extended power range and battery-powered systems
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- STMicroelectronics IO-Link Actuator Board Brings Turnkey Reference Design to Industrial Monitoring and Equipment Manufacturers
- EEWORLD University Hall----Live playback: AM57X platform features and typical applications
- 【ST NUCLEO-H743ZI Review】(1) First experience lighting up the LED
- Failed DIY portable antenna for mobile phone radio
- TI C64X+ General Library Function User Manual
- The principle and application of real-time voice change processing chip SD771D
- bluenrg chat example
- Is it a trend to use Matlab's automatic code generation for controller development?
- GPS Device Terminology Explained
- UART interface algorithm transplantation encryption chip debugging skills - algorithm debugging
- Power module packaging structure and technology