How to use the available function generator of the microcontroller as a serial port transmitter

If you want to debug the serial port, there is only one switch and the computer is not at hand, you can use the function generator as the serial port transmitter. If your baud rate is 9600, then you can adjust the function generator frequency to 9600/2 =4800HZ output TTL level directly to RXD, if it is an RS232 interface, you can choose the function generator bipolar (AC output) if the frequency remains unchanged, pay attention to the peak-to-peak level of 12VPP is enough, this When your microcontroller receives the data, it must be 55H. You can use MOV P1, SBUF to measure the voltage on P1, so that the serial port can be tested even if it is not displayed.

1. Function generator can be used as serial transmitter

If you want to debug the serial port, there is only one switch and the computer is not at hand, you can use the function generator as the serial port transmitter. If your baud rate is 9600, then you can adjust the function generator frequency to 9600/2 =4800HZ output TTL level directly to RXD, if it is an RS232 interface, you can choose the function generator bipolar (AC output) if the frequency remains unchanged, pay attention to the peak-to-peak level of 12VPP is enough, this When your microcontroller receives the data, it must be 55H. You can use MOV P1, SBUF to measure the voltage on P1, so that the serial port can be tested even if it is not displayed.

How to use the available function generator of the microcontroller as a serial port transmitter. 0 (start) 101010101 (stop). Exactly a square wave of 1/2 baud rate.

2. If your serial port needs to realize long-distance transmission, how do you know the reliability of the transmission and the adaptability of the signal and the transmission medium?

You can do this: send 00H 0FFH 55H, if these three values ​​can be accepted correctly, then the network must be able to transmit reliably. This is the test method using points instead of planes.

Reason: 00H 0FFH is the widest pulse and the pulse with the maximum/minimum level (representing energy). In the signal system, they represent DC, while 55H is the narrowest pulse, which represents the highest frequency and the middle value of energy. Since the lowest energy can pass, the largest can pass, the widest can pass the narrowest, and the high energy (strong anti-interference) and low energy (represents weak anti-interference) energy can also pass, you will believe that the middle and the middle are not. Can’t get over the rubbish!

3. Use the sync header to initially implement the baud rate adaptation and judge the start of the data packet. Who is used for the sync header? ——7FH, and send continuously when starting synchronization!

Watch 7FH send 0 start 11111110-1 stop

Look how symmetrical 011111110 is! When you receive data with a continuous 1 sandwiched between two 0s, just divide the time of the continuous 1 by the duration of 0 = 7, indicating that this is the synchronization header, and the duration of a standard symbol is symbol 0 The duration of , whose baud rate = 1/(0 symbol duration).

The Links:   MG50J2YS9 CM150DY-12E

Related Posts