EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Read a character from serial port and send back

Read a character from serial port and send back

|

Electronics › Electronics › Read a character from serial port and send back

  • This topic has 4 replies, 3 voices, and was last updated 12 years, 3 months ago by umar farrok.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • March 8, 2013 at 11:36 am #2170
    Pavithra
    Participant

    Hi Engineers Garage and all ;)

     

    I have a query regarding serial communication. I need to read a character from serial port and send them back. Ive written the code but not getting expected result. :( Please u experts help me.. I would be very happy :]

    This is my assembly code

     

    ORG 000H
    MOV TMOD,#20H
    MOV TH1,#0FDH
    MOV SCON,#50H
    SETB TR1

    r:JNB RI,R
        MOV A,SBUF
        MOV P1,A
        CLR RI
        SJMP R

    HERE:JNB TI,HERE
    CLR TI
    AGAIN:MOV P2,SBUF
    SJMP AGAIN
    END

     

    PLease guys help me and suggest me wat m i doin wrong . :(  waiting for ur reply :)

    March 9, 2013 at 2:35 pm #9284
    Savio
    Participant

    Hey Pavithra,

     

    I tried simulating your code and there are some points you should note.

     

    1. Use ‘ ACALL r ‘ to make a recieve function and end it with ‘ RET ‘. In your code ‘SJMP r’ will loop forever in the ‘r’ subroutine and never execute the sending subroutine.

     

    2. The data you are recieving is on ‘P1’ , but you are transmitting data from ‘P2’ .

     

    3. If you are simulating, check that the clock is set to 11.0592MHz only.

     

    This is your code which I made some changes to, hope it helps.

     

    ORG 000H
    MOV TMOD,#20H
    MOV TH1,#0FDH
    MOV SCON,#50H
    SETB TR1
    ACALL r
    ACALL t

    r:JNB RI,R
        MOV A,SBUF
        MOV P1,A
        CLR RI
        RET

    t:    MOV P1, A
        MOV SBUF, A
    w:    JNB TI,w
        CLR TI
        
        RET
    END

     

    Regards.

    March 10, 2013 at 12:30 pm #9288
    Pavithra
    Participant

    thank you so much for ur suggestions.. Im gonna try this out and hope so it would work ..

     

    with regards.

    March 11, 2013 at 5:25 am #9292
    Pavithra
    Participant

    Sorry to say this, this code dint work. :(

    March 28, 2013 at 6:19 am #9380
    umar farrok
    Participant

    try this code 

    SCON=0X50;

    TMOD=0X20;

    TL1=TH1=0XFD;

    TR1=1;

     inside main

    while(RI==0);

    {

    RI=0;

    msg=SBUF;

    SBUF=msg;

    while(TI==0);

    TI=0;

    }

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Sump pit water alarm - Kicad 9 July 18, 2025
  • Pic18f25q10 osccon1 settings swordfish basic July 17, 2025
  • Anyone jumped from Easyeda std to Easyeda pro? July 17, 2025
  • turbo jet fan - feedback appreciated. July 17, 2025
  • More fun with ws2812 this time XC8 and CLC July 17, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise