Some Wrongs Occurred When Sending Data to Serial Port

Hi,
When the 90C51(this one: http://www.kynix.com/Detail/1155503/90C51-G267.html ) serial port sends data to serial debugging assistant,there are some wrongs occurred.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
**************************************************************************/
The baud rate is 9600,way 1。
#include<reg51.h>
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define uint unsigned int
#define uchar unsigned char
void UsartConfiguration();
void Delay10ms(unsigned int c);   


*******************************************************************************/

int i;
        int j[5]={0};
void main()
{
        UsartConfiguration();
        while(1)
        {

                j[0]=1;
                j[1]=2;
                j[2]=3;
                j[3]=4;
                j[4]=5;
   for(i=0;i<5;i++)
        {        SBUF=j;
                while(!TI);                  //µÈ´ý·¢ËÍÊý¾ÝÍê³É
                TI=1;        
}
                Delay10ms(200);                  //ÑÓʱһÏÂÔÙ·¢
        
}}
/*******************************************************************************

void UsartConfiguration()
{
        SCON=0X50;                        
        TMOD=0X20;                        
        PCON=0X00;                        
        TH1=0XFD;                  
        TL1=0XFD;
        ES=1;                                                
        EA=1;                                                
        TR1=1;                                           
}


void Delay10ms(unsigned int c)   
{
    unsigned char a, b;

    for (;c>0;c--)
        {
                for (b=38;b>0;b--)
                {
                        for (a=130;a>0;a--);
                }          
        }       
} */

I am sending data one by one, so the output should be 01,02,03,04,05. But it isn’t.
When the data bits is seven( 05 05 04 03 02 01 05 05 04 03 02 01 05 05。。。),it will output: C:\Users\me\Desktop\MM1
When the data bits is eight( 85 85 84 83 82 81 85 85 84 83 82 81 85 85。。。 ),it will output: C:\Users\me\Desktop\MM2
However,the data bits I set in MCU is eight while stop bit is one.I don’t know where went wrong?
Last edited on
its been a while but the 4 settings that matter on a serial port are the speed match (you have this, or you would get total random junk) and the N-8-1 settings (this is the standard that most everything used in the later years of serial ports, the other settings were generally only seen on even older stuff).

If you have the 8 and 1, check the N setting.

All 4 settings on the source and target ports have to match or you get strange behavior. This looks like what you might see with N-8-0 vs N-8-1 conflict, but I am guessing and havent used a serial port in 10+ years.

Topic archived. No new replies allowed.