14533 views|8 replies

3

Posts

0

Resources
The OP
 

Serial port data reception and transmission are unstable and require hardware reset [Copy link]

  I wrote a program for the stc12c5a60s2 microcontroller. One serial port collects current module data, and one timer collects frequency. The data is sent through another serial port. At first, the data can be collected for a period of time after power-on. Later, the current data is always 0.00, and the frequency data is normal. After the hardware is reset, it can work normally again. Please tell me where the problem is

test.c

5.65 KB, downloads: 4

This post is from MCU

Latest reply

Check whether the collected data is correct when the problem occurs. If the collected data is correct, check whether it is incorrect after forwarding. Check where the program logic processing is wrong.  Details Published on 2018-5-20 02:21
 

1w

Posts

142

Resources
2
 
There is too little information to judge.
This post is from MCU
 
Personal signature上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
 

1w

Posts

142

Resources
3
 
If you want to get timely and effective help, first learn to describe the problem correctly and completely, and the more detailed the better.
This post is from MCU
 
Personal signature上传了一些书籍资料,也许有你想要的:https://download.eeworld.com.cn/user/chunyang
 
 

4177

Posts

9

Resources
4
 
Look at your description. You only use two peripherals, a serial port and a timer. First check the hardware problem of your circuit. If there is no problem with the hardware (mainly focus on the design of the crystal oscillator circuit and the reset circuit, as well as Vcc decoupling and some key instructions in the datasheet), then check the problem of the software you wrote. Debug the serial port first. After the serial port has no problem at all. You can consider using the serial port to print first, and monitor the data for a period of time on the serial port debugging assistant. Finally, if there is no problem with the above, consider connecting to other serial ports for communication.
This post is from MCU
 
 
 

3

Posts

0

Resources
5
 
huaiqiao posted on 2018-5-17 20:21 Have you read your description? You use two peripherals, a serial port and a timer. First check the hardware problem of your circuit. If there is no problem with the hardware...
There is no problem with the hardware. When I output hexadecimal numbers, I have been debugging without any problems. When I convert them to strings and send them in packages, problems will occur after a period of testing. The timer is normal, so the frequency data is correct, but the first 3 data are abnormal and are always 0.00 in the array. Where should I add a watchdog program?
This post is from MCU

Comments

Another factor in serial communication is the baud rate, which depends on your communication distance. "Problems will occur after a period of detection" Why not use the serial debugging assistant first? Serial port printing can help you check whether the data is correct  Details Published on 2018-5-17 23:06
 
 
 

4177

Posts

9

Resources
6
 
heguojian posted on 2018-5-17 22:23 There is no problem with the hardware. When I output hexadecimal numbers, I have been debugging without any problems. When I convert them into strings and send them in packets, after testing for a period of time...
Another factor in serial communication is the baud rate, which depends on your communication distance. "Problems will occur after testing for a period of time" Why not use the serial debugging assistant first? Serial port printing can help you determine whether the data is correct
This post is from MCU
 
 
 

3

Posts

0

Resources
7
 
huaiqiao posted on 2018-5-17 23:06 Another factor in serial communication is the baud rate, which depends on your communication distance. "Problems will occur after a period of detection" Why not...
I used the serial debugging assistant to check, and the baud rate was 9600, which means that the detection equipment has interference, which will make the microcontroller seem to fail.
This post is from MCU

Comments

Because I don't know your site environment, so I can't tell you. But it may also be a problem with your program. Of course, what you said is also possible.  Details Published on 2018-5-17 23:53
 
 
 

4177

Posts

9

Resources
8
 
heguojian posted on 2018-5-17 23:43 I used the serial port debugging assistant to check, and the baud rate was 9600. It was the detection equipment that had interference, which made the microcontroller seem to fail
Because I don’t know the environment at your site, I can’t tell you for sure. . . . . . But it could also be a problem with your program. Of course, what you said is also possible
This post is from MCU
 
 
 

3471

Posts

11

Resources
9
 
Check whether the collected data is correct when the problem occurs. If the collected data is correct, check whether it is incorrect after forwarding. Check where the program logic processing is wrong.
This post is from MCU
 
 
 

Guess Your Favourite
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