+ Post New Thread
Results 1 to 19 of 19
  1. #1
    Member level 1
    Points: 789, Level: 6

    Join Date
    Nov 2011
    Posts
    32
    Helped
    1 / 1
    Points
    789
    Level
    6

    8051 micro with max232 serial communication problem

    I am trying to send a character from At89S52 mc to my PC through com1 port. All I am getting is garbage. My schematic, code, screen shots of output (both putty and Hyper Terminal), picture of DB9 female port is given. (The com1 port of PC is working fine as I use that port for my pic programmer.)
    Thanks in advance

    #include<8051.h>
    main(){
    TMOD=0x20;
    TH1=0xFA;
    SCON=0x50;
    TR1=1;
    while(1){
    SBUF='M';
    while(TI==0);
    TI=0;
    }
    }

    Click image for larger version. 

Name:	circuit_232.jpg 
Views:	66 
Size:	23.8 KB 
ID:	65481Click image for larger version. 

Name:	port.gif 
Views:	18 
Size:	803.6 KB 
ID:	65482Click image for larger version. 

Name:	screen_putty.PNG 
Views:	20 
Size:	12.8 KB 
ID:	65483Click image for larger version. 

Name:	screen_hyt.PNG 
Views:	24 
Size:	17.4 KB 
ID:	65484
    Hyperterminal settings:-
    Bits per Sec:4800
    Data bits:8
    H/W Flowcontrol:none
    Pairty:none
    Stop bits:1
    Last edited by bimalkamal; 10th December 2011 at 06:57.

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 5
    Points: 74,061, Level: 66

    Join Date
    Oct 2004
    Location
    West Coast
    Posts
    7,942
    Helped
    2329 / 2329
    Points
    74,061
    Level
    66

    Re: 8051 micro with max232 serial communication problem

    try this:

    Code:
    {
    tmod=0x20;
    scon=0x50;
    tl1=0xfa;
    th1=0xfa;
    tr1=1;
    while ...
    }

    IanP



  3. #3
    Newbie level 4
    Points: 254, Level: 3

    Join Date
    Oct 2011
    Posts
    7
    Helped
    0 / 0
    Points
    254
    Level
    3

    Re: 8051 micro with max232 serial communication problem

    Connect ground wire to pin 5 of db9



  4. #4
    Member level 1
    Points: 789, Level: 6

    Join Date
    Nov 2011
    Posts
    32
    Helped
    1 / 1
    Points
    789
    Level
    6

    Re: 8051 micro with max232 serial communication problem

    DB9 pin 5 has already been connected to Ground.

    The code as suggested by IanP gives the same result in putty but Hyperterminal showing "9b"
    TMOD=0x20;
    SCON=0x50;
    TL1=0xfa;
    TH1=0xfa;
    TR1=1;
    while(1){
    SBUF='M';
    while(TI==0);
    TI=0;
    }



  5. #5
    Super Moderator
    Points: 10,811, Level: 24
    Achievements:
    Created Blog entry 7 years registered

    Join Date
    Jul 2007
    Location
    Sri Lanka
    Posts
    1,737
    Helped
    300 / 300
    Points
    10,811
    Level
    24
    Blog Entries
    3

    Re: 8051 micro with max232 serial communication problem

    try this

    1. check one character at a time

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    TMOD=0x20;
    SCON=0x50;
    TL1=0xfa;
    TH1=0xfa;
    TR1=1;
     
    SBUF='M';
    while(TI==0);
    TI=0;
     
    while(1){
    }


    2. Introduce small delay between two sending sequence.

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    TMOD=0x20;
    SCON=0x50;
    TL1=0xfa;
    TH1=0xfa;
    TR1=1;
    while(1){
    SBUF='M';
     
    put some delay here
     
    while(TI==0);
    TI=0;
    }



  6. #6
    Member level 1
    Points: 789, Level: 6

    Join Date
    Nov 2011
    Posts
    32
    Helped
    1 / 1
    Points
    789
    Level
    6

    Re: 8051 micro with max232 serial communication problem

    Second code with SBUF=0x41; giving output 'b'.



  7. #7
    Junior Member level 1
    Points: 2,266, Level: 11

    Join Date
    Sep 2002
    Posts
    15
    Helped
    1 / 1
    Points
    2,266
    Level
    11

    Re: 8051 micro with max232 serial communication problem

    HI:
    c51 code is ok!
    / / Crystal 11.0592 4800 baud
    but you code no delay
    =================
    #include<8051.h>
    main(){
    TMOD=0x20;
    TH1=0xFA;
    SCON=0x50;
    TR1=1;
    while(1){
    SBUF='M';
    while(TI==0);
    TI=0;
    delay code
    }
    }

    Good luck!!



    •   AltAdvertisement

        
       

  8. #8
    Member level 1
    Points: 789, Level: 6

    Join Date
    Nov 2011
    Posts
    32
    Helped
    1 / 1
    Points
    789
    Level
    6

    Re: 8051 micro with max232 serial communication problem

    #include<8051.h>
    main(){
    TMOD=0x20;
    TH1=0xFA;
    SCON=0x50;
    TR1=1;
    while(1){
    SBUF='M';
    while(TI==0);
    TI=0;
    MSDelay(300);
    }
    }

    Same output. Only showing 'b' in Hyperterminal. It appears that whatever change I make. I see only 'b'. Apart from hyperterminal, I have also used putty and Uart.exe.
    Uart.exe displays - ASCII char -ג Decimal - 226 Hex - 0xE2



  9. #9
    Super Moderator
    Points: 10,811, Level: 24
    Achievements:
    Created Blog entry 7 years registered

    Join Date
    Jul 2007
    Location
    Sri Lanka
    Posts
    1,737
    Helped
    300 / 300
    Points
    10,811
    Level
    24
    Blog Entries
    3

    Re: 8051 micro with max232 serial communication problem

    try sending different characters, also check your hardware again



    •   AltAdvertisement

        
       

  10. #10
    Junior Member level 1
    Points: 2,266, Level: 11

    Join Date
    Sep 2002
    Posts
    15
    Helped
    1 / 1
    Points
    2,266
    Level
    11

    Re: 8051 micro with max232 serial communication problem

    check your RS232 (Pin5.) must connect GND!!



  11. #11
    Member level 1
    Points: 789, Level: 6

    Join Date
    Nov 2011
    Posts
    32
    Helped
    1 / 1
    Points
    789
    Level
    6

    Re: 8051 micro with max232 serial communication problem

    Now The code is :-
    #include<8051.h>
    #include
    void sendx(unsigned char x);

    main(){
    TMOD=0x20;
    TH1=0xFA;
    SCON=0x50;
    TR1=1;

    while(1){
    sendx('a');
    sendx('b');
    sendx('c');
    sendx('A');
    sendx('B');
    sendx('C');
    }
    }

    void sendx(unsigned char x){
    SBUF=x;
    while(TI==0);
    TI=0;
    DelayMs(200);

    }

    And The output in Hyperterminal:-
    אבבטייאבבטייאבבטייאבבטייאבבטייאבבטייאבבטייאבבטייאב בטייאבבטייאבבטייא
    בבטייאבבטייאבבטייאבבטייאבבטייאבבטייאבבטייאבבטייאבב טייאבבטייאבבטייאבבטייאבבטייאבב
    טייאבבטייאבבטייאבבטייאבבטייאבבטייא



  12. #12
    Advanced Member level 4
    Points: 6,918, Level: 19
    Achievements:
    Created Blog entry Created Album pictures 7 years registered
    alexxx's Avatar
    Join Date
    Apr 2011
    Location
    Greece
    Posts
    1,013
    Helped
    278 / 278
    Points
    6,918
    Level
    19
    Blog Entries
    2

    Re: 8051 micro with max232 serial communication problem

    One common bug in RS232 communication with PC, is not matched baudrates. So verify that the baudrate from PC's side is the same as the baudrate from MCU's side. Since you are getting wrong characters in hyperterminal, this could be a possible reason.


    1 members found this post helpful.

  13. #13
    Newbie level 4
    Points: 254, Level: 3

    Join Date
    Oct 2011
    Posts
    7
    Helped
    0 / 0
    Points
    254
    Level
    3

    Re: 8051 micro with max232 serial communication problem



    check ur connection like this...may be this will help...



  14. #14
    Advanced Member level 4
    Points: 6,918, Level: 19
    Achievements:
    Created Blog entry Created Album pictures 7 years registered
    alexxx's Avatar
    Join Date
    Apr 2011
    Location
    Greece
    Posts
    1,013
    Helped
    278 / 278
    Points
    6,918
    Level
    19
    Blog Entries
    2

    Re: 8051 micro with max232 serial communication problem

    Quote Originally Posted by vivek5239 View Post


    check ur connection like this...may be this will help...
    First of all it is good to post the datasheet for reference.
    MAX232 pdf, MAX232 description, MAX232 datasheets, MAX232 view ::: ALLDATASHEET :::

    Used capacitors must have a value of 100nF, but you are using 10uF.
    On RS232 connector, pin 2 and 3 signals should be inverted with each other (unless you don't use a cross cable). Except from pins 2, 3 and 5 on this connector, you don't need other connections. I can't tell if the extra connections you are using there, are right or wrong. I have never wired anything else on a DB9 except those three pins I mentioned.

    Furthermore it is a common habit to use T1 with R1 together and T2 with R2 together. I suppose it will work with your way also, but never seen this kind of connection before.
    I hope I didn't miss something, please change your circuit according to datasheet.



  15. #15
    Newbie level 1
    Points: 912, Level: 6

    Join Date
    Jan 2011
    Location
    Rawalpindi
    Posts
    1
    Helped
    0 / 0
    Points
    912
    Level
    6

    Re: 8051 micro with max232 serial communication problem

    Please see my example for 8051 interfacing to PC serial port http://www.micro-digital.net/pc-seri...rface-to-8051/. It is working example with 9600 baud rate. Hyperterminal file is include in whole project zip file. For more examples see project page of site http://www.micro-digital.net/projects



  16. #16
    Full Member level 5
    Points: 2,342, Level: 11
    Jigar 4 Electronics's Avatar
    Join Date
    Apr 2011
    Location
    Hamilton, ON, Canada
    Posts
    313
    Helped
    40 / 40
    Points
    2,342
    Level
    11
    Blog Entries
    2

    Re: 8051 micro with max232 serial communication problem

    Don't give any kind of delay while using hyper terminal...
    cut the delay function from the program and then try it again.
    If you still not getting the o/p then I'll send you the files to do so.

    All The Best :)
    Never Leave it until you did it.
    Every time you fails go for one more time :)



    •   AltAdvertisement

        
       

  17. #17
    Banned
    Points: 6,265, Level: 18

    Join Date
    Jul 2012
    Posts
    1,192
    Helped
    172 / 172
    Points
    6,265
    Level
    18

    Re: 8051 micro with max232 serial communication problem

    Which compiler are you using?

    I am getting this.
    Last edited by internetuser2k12; 1st September 2012 at 08:46.



  18. #18
    Newbie level 3
    Points: 83, Level: 1

    Join Date
    Jul 2012
    Posts
    3
    Helped
    0 / 0
    Points
    83
    Level
    1

    Re: 8051 micro with max232 serial communication problem

    HEllo Everyone

    I am also getting same kind of problem and the possible reason, Which I have understood is as follows. The Mode 1 of SMOD serial Communication, frames the bit as 10 bit frame 1 start, 8 data bit and 1 stop bit. bUt the hyper terminal assumes 9 bit frame 8-data bit and 1 stop bit. So we should make the frame size same to have communication.

    BUt ALAS....>! I have checked hardware manual 8051, and I have not got any solution in which 10 bit frame could be readjusted to 9 bit .

    Any help is much appreciated....!



  19. #19
    Advanced Member level 3
    Points: 6,510, Level: 19
    Achievements:
    7 years registered

    Join Date
    Jun 2009
    Location
    India
    Posts
    856
    Helped
    163 / 163
    Points
    6,510
    Level
    19

    Re: 8051 micro with max232 serial communication problem

    I too experienced Hyperterminal working to by fishy. Other software work far better.



--[[ ]]--