STC89C52RC serial port baud rate program

First, 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');

}

}

Second, the remarks

The "SCON_init" subroutine is a subroutine for serial port baud rate setting and initialization, which can be called once at the beginning of the main program. In the entire serial port baud rate initialization subroutine, we have the complete code in both ways. The code that is not marked with the comment symbol is the 6T mode mode. The comment symbol is marked by the timer 2 in the 12T mode. Code.

The setting of 6T or 12T mode is selected by the programmer when programming, and no code setting is required. Timer 2 is only available on the STC89C52RC, an enhanced 51 microcontroller.

Other product

Other product,Sexual Enhancement Capsule,Long Time Sex Capsule,Fast Erection Capsule,Sex Power Capsule

Nanning Goodman Technology Co.,Ltd , https://www.goodmentech.com