This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to simulate UART program in Keilc51

Sir,
Here is my UART program...
$
org 000h
ljmp begin
org 23h
ljmp serial_IT
;/**
; * FUNCTION_PURPOSE: This file set up uart in mode 1 (8 bits uart) with
; * timer 1 in mode 2 (8 bits auto reload timer).
; * FUNCTION_INPUTS: void
; * FUNCTION_OUTPUTS: void
; */
org 0100h
begin:
MOV SCON, #50h; /* uart in mode 1 (8 bit), REN=1 */
ORL TMOD, #20h; /* Timer 1 in mode 2 */
MOV TH1, #0FDh; /* 9600 Bds at 11.059MHz */
MOV TL1, #0FDh; /* 9600 Bds at 11.059MHz */
SETB ES; /* Enable serial interrupt*/
SETB EA; /* Enable global interrupt */
SETB TR1; /* Timer 1 run */
JMP $; /* endless */
;/**
; * FUNCTION_PURPOSE: serial interrupt, echo received data.
; * FUNCTION_INPUTS: P3.0(RXD) serial input
; * FUNCTION_OUTPUTS: P3.1(TXD) serial output
; */
serial_IT:
JNB RI,EMIT_IT ; test if it is a reception
CLR RI ; clear reception flag for next reception
MOV A,SBUF ; read data from uart
MOV SBUF,A ; write same data to uart
LJMP END_IT
EMIT_IT:
CLR TI ; clear transmition flag for next transmition
END_IT:
RETI
end

This program is taken from ATMEL SITe..

when i simulate it....during simulation how do i give serial input?
When u just run it,setting RI manually...check out SBUF value...no value in it???

How to give serial input??

Since port 3 (P3.0 (RXD) and P3.1 (TXD) ) is used for serial communication..
how to set p3.1 as output pin and p3.0 as input pin??

Thank you.
Tushar

Parents Reply Children
  • Sir,
    Thnx for ur help..my program is runnning successfully now...i can give the input and print the output on serial window...

    Still hv some questions regarding serial window.

    In my hardware module i am using P3.0 as RXD and P3.1 as TXD.

    NOTE :: P3.0 and P3.1 are not connected to the serial port of computer.
    They are connected to RX and TX pins of RF transmitter/Receiver module.

    Now when i give the input through serial window how do i come to know that it is coming from P3.0 (Or by default it comes from there only?)
    Same is the case when i am transmitting...how do i come to know whether character that i am transmitting gets transmitted from P3.1?

  • "NOTE :: P3.0 and P3.1 are not connected to the serial port of computer.
    They are connected to RX and TX pins of RF transmitter/Receiver module."


    But in the Simulator they are not connected to anything at all - they don't even exist!!

    "Now when i give the input through serial window how do i come to know that it is coming from P3.0"

    Typing in the Serial Window simulates data arriving at P3.0

    "Same is the case when i am transmitting...how do i come to know whether character that i am transmitting gets transmitted from P3.1?"

    It doesn't - it appears in the Serial Windows to simulate data being transmitted from P3.1!