-
Send the data you want to send from low to high according to the hexadecimal, if you want to send character 1, the corresponding hexadecimal is 0x31, and the sending format is 10001100.
-
To communicate with a PC, 51 should choose eight asynchronous communication modes.
It is also possible that the baud rate of your PC or microcontroller is inaccurate.
51 microcontroller communication, we recommend the use of crystal oscillator, so common in the baud rate of the PC, you can get a small error, most of the baud rate can get a theoretical zero error.
-
Write casually, the meaning of the representative is determined by yourself, and the single-chip microcomputer receives it and then identifies each data classification function according to the previous limitation.
-
Generally, the character values that are sent through the serial port assistant are numeric in the past.
-
8-bit binary storage, of course.
-
51. MCU simulates serial mouse communication.
-
I want to do it too, I want to make analog keyboards to play Super Marie ......
-
You can send the data in the form of a packet, for example, 0x1111, then you can put the 16-bit definition as a character in the form of an array, and finally send the data out of the array name (that is, the first address), so that there will be no data overflow problem.
-
Are you going to implement UART functionality with IO simulation? That is to write the IO control according to the baud rate and the UART sending data format (start bits, data bits, check bits, stop bits).
-
The general "serial port sending interface" provides string mode sending and hexadecimal sending, you say, "convert to characters."
This is the former;
Workaround: Select the hexadecimal sending mode.
-
One byte produces 16 characters is two characters, and when restoring, it is enough to restore one byte for every two characters.
Send: 1a---'1' 'a'
Receiving:'1'---1,'a'--- 101*16+10=26 is 1a, it becomes a byte. Very simple.
-
Just tick that hex when you send it.
-
If you look at the send-string function, string refers to a string, and the input parameter should be a pointer type, yes.
Enter the name in the array, or you can directly enter a string of accommodating characters such as i love you with quotation marks, and send an ASCI code.
If you want to send data, you can write a function to send data, or convert the data variable to an address, such as uchar a=0x38 you want to send a value can be send-string(&a).
If the receiver is in hexadecimal format, it will display decimal 56 or 0x38
If it is in text mode, 8 will be displayed
Send a series of data A 4]=
send-string(a).
Of course, you can send strings and data at the same time, first convert the data into strings (arrays), and then use string concatenation functions to synthesize the original strings and data strings into an array, and send them again.
The receiver can only receive it in one way, either in text or hexadecimal.