Home > other >  51 microcontroller serial communication, with the matrix button to send data when the Chinese will b
51 microcontroller serial communication, with the matrix button to send data when the Chinese will b

Time:09-26

# include & lt; Reg52. H>
Typedef unsigned int under-16;
Typedef unsigned char u8;
U8 KeyValue;
# define GPIO_KEY P1
Unsigned char code anjian []={" 10 "};
Unsigned char I, j;
Bit flag.
Void delay (unsigned int n)
{
Unsigned char a, b;
for(a=0; AFor (b=0; B<123; B++);

}


Void UsartInit ()
{
SCON=0 x50;
TMOD=0 x20;
PCON=0 x80;
TH1=0 xf3;
TL1=0 xf3;
//ES=1;
//EA=1;
TR1=1;
}

Void Send_string (unsigned char c)
{
SBUF=c;
While (TI==0);
TI=0;
}
Void the key ()
{
GPIO_KEY=0 x0f;
If (GPIO_KEY!=0 x0f)
{delay (100);
If (GPIO_KEY!=0 x0f)
{GPIO_KEY=0 x0f;
The switch (GPIO_KEY)
{
Case (0 x07) : KeyValue=https://bbs.csdn.net/topics/0; break;
Case (0 x0b) : KeyValue=https://bbs.csdn.net/topics/1; break;
Case (0 x0d) : KeyValue=https://bbs.csdn.net/topics/2; break;
Case (0 x0e) : KeyValue=https://bbs.csdn.net/topics/3; break;
}
//2 ae? DD
GPIO_KEY=0 xf0;
The switch (GPIO_KEY)
{
Case (0 x70) : KeyValue=https://bbs.csdn.net/topics/KeyValue; break;
Case (0 xb0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+4; break;
Case (0 xd0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+8; break;
Case (0 xe0-0xfc) : KeyValue=https://bbs.csdn.net/topics/KeyValue+12; break;
}
I=KeyValue;
Send_string (anjian [I]);
delay(10);
}

}
}


Void main (void)
{
UsartInit ();
While (1) {key (); }}

CodePudding user response:

Baud rate isn't kept at just the right, have the code that transport, try a lower baud rate

CodePudding user response:

1. Check the baud rate matches the
2. Check the display is the hexadecimal or characters

CodePudding user response:

refer to the second floor yishumei response:
1. Check the baud rate matches the
2. Check the display is the hexadecimal or character

In text mode, baud rate is adjustable, digital can send English, send Chinese would be a question mark, there is only a question mark

CodePudding user response:

The Chinese encoding format is wrong

CodePudding user response:

reference 4 floor aijie099 response:
Chinese encoding format wrong

How to edit, can, for example, to find for a long time did not find on the Internet

CodePudding user response:

Your ides of setting the encode set to utf8 inside
  • Related