Recently, I saw a friend on the Internet asking how the single chip microcomputer sends a string of Chinese characters to the computer. In fact, this problem is not difficult. ha-ha. As long as the relevant parameters are set well, and then the Chinese characters are defined as a group of characters and sent to the computer.

In order to let you know more clearly, I wrote the following program to demonstrate it.

Operating conditions:

1. XP operating system.

2. XP HyperTerminal display.

3.WJ-V4. 0 development board.

4. Single chip microcomputer STC89C52

5. Crystal oscillator 11.0592m

Operation steps:

1. Set tmod, set baud rate and working mode of timer 1.

2. Set the initial value of the timer.

3. Set the working mode of serial port.

4. Set the baud rate not to double.

5. Turn on Tr1 to allow transmission.

6. Start the timer.

7. Serial interrupt on.

8. Open EA interrupt.

Now send the source code:


#defineucharunsigned char

#defineuint unsigned int

bitFS_ Bit = 0;// Send flag bit

codeuchar TEXT0[] = “********************************rnn”;

Codeuchar text1 [] = “welcome to the e-enthusiast community! RNN”;

codeuchar TEXT2[] = “!rnn”;

Codeuchar Text3 [] = “51 free development board PCB free! RNN”;

Codeuchar Text4 [] = “gift address” ? id=2rnn”;

codeuchar TEXT5[] = “********************************rnnnnn”;

void Delay_ Ms(uint i);// Delay Functions

voidUART_ Char(uchar Value);// Send a data

void Prints(uchar *Value);// Send a set of data

void main(void)


TMOD = 0x20;// Set the baud rate to 9600 and the working mode of timer 1

TL1 = 0xFD;// Set initial value

TH1 = 0xFD;

SCON = 0x50;// Set the working mode of serial port

PCON = 0x00;

TR1 = 1;// Allow sending

ET0 = 1;// Start timer

ES = 1;// Serial interrupt enable

EA = 1;



Prints(TEXT0);// send data






Delay_ Ms(60000);// delayed



void INIT_ Uart(void)interrupt 4


If (RI) / / if data is received


RI = 0;




TI = 0;// Send a data

FS_ Bit = 0;// Clear mark



void Uart_ Char(uchar Value)


SBUF = Value;// send data

FS_ Bit = 1;// Set send flag bit



void Prints(uchar *Value)


while((*Value) != ‘’)// If not sent


Uart_ Char(*Value);// Send one bit data

Value++;// The pointer points to the next data bit



void Delay_ Ms(uint i)


while(–i );


Finally, let’s see the effect picture of the program:

How to send a string of Chinese characters to the computer by single chip microcomputer

Leave a Reply

Your email address will not be published. Required fields are marked *