2191 views|0 replies

1662

Posts

0

Resources
The OP
 

How to use the available function generator of a microcontroller as a serial port transmitter [Copy link]

 1. Use a function generator as a serial port transmitter
  If you want to debug the serial port, but you only have a board and the computer is not at hand, you can use a function generator as a serial port transmitter. For example, if your baud rate is 9600, then you can adjust the function generator frequency to 9600/2=4800HZ and output the TTL level directly to RXD. If it is an RS232 interface, you can choose the bipolar function generator (AC output) without changing the frequency. Note that the peak-to-peak value of the level is 12VPP. At this time, the data received by your microcontroller must be 55H. You can use MOV P1, SBUF to measure the voltage on P1. In this way, you can test the serial port even if there is no display.
  How to use the microcontroller's function generator as a serial port transmitter The theory remains the same: 55H is 01010101 The serial port start bit is 0, and the lowest bit of 55H is sent first, so a frame is 0 (start) 101010101 (stop). 0 (start) 101010101 (stop). It is exactly a square wave of 1/2 baud rate.
  2. If your serial port is to achieve long-distance transmission, how do you know the reliability of transmission and the adaptability of the signal to the transmission medium?
  You can do it like this: send 00H 0FFH 55H. If these three values can be correctly received, then the network must be able to transmit reliably. This is the test method of using points to represent the whole.
  Reason: 00H 0FFH is the widest pulse and the pulse with the maximum/minimum level (representing energy). In the words of the signal system, they represent direct current, and 55H is the narrowest pulse, which represents the highest frequency and the middle value of energy. Since the lowest can pass, the largest can also pass, the widest can pass, the narrowest can also pass, high energy (strong anti-interference), low energy (representing weak anti-interference), and medium energy can also pass, do you believe that the middle and the medium-non-junk can not pass!
  3. Use the synchronization header to initially realize baud rate adaptation and determine the start of the data packet. Which synchronization header is used? ------7FH, and send continuously when starting synchronization!
  Look at the transmission of 7FH, 0 starts, 11111110 --- 1 stops.
  Look how symmetrical 011111110 is! When you receive data with consecutive 1s between two 0s, just divide the duration of consecutive 1s by the duration of 0s = 7, which means this is the synchronization header, and the duration of a standard code element is the duration of code element 0, and its baud rate = 1/(duration of code element 0)

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list