Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to send integer data from single chip microcomputer to serial port debugging wizard
How to send integer data from single chip microcomputer to serial port debugging wizard
The key to the problem is that the serial port sends up to 8 binary bits at a time, which is one byte. Therefore, the amount of shaping must always be unpacked and sent. As for whether it is decomposed into bits, bytes or strings, it is a matter of communication protocol, or it can be arbitrary (you don't have any more explanations, so I assume that the protocol is up to you).

The For loop can be used completely, as long as there is enough time delay between two bytes, which depends on the baud rate. Usually the baud rate multiplied by the reciprocal of 10 is the time for serial hardware to send a byte, and the delay is longer than this.

About supplement:

That's the problem of programming algorithm. For example, the ASCII codes you receive are "1", "7" and "8". If you subtract the ASCII code of "0" respectively, it becomes three numbers: 1, 7 and 8, and then1*100+7 */kloc-. Generally, the following programming algorithms can be used to "synthesize" the numbers represented by each bit into corresponding values:

Unit number+10* (ten digits+10* (hundred digits+10* (thousand digits+...)). ....