0% found this document useful (0 votes)
15 views3 pages

RS-232 Comm

The document outlines a program for RS232 communication using an 8051 microcontroller, detailing hardware and software requirements, as well as the RS-232 protocol features. It includes step-by-step instructions for setting up the program in Keil uVision and provides source code for initializing serial communication, transmitting, and receiving data. The expected output in the UART Serial Window is 'HELLO'.

Uploaded by

viquarsultana135
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

RS-232 Comm

The document outlines a program for RS232 communication using an 8051 microcontroller, detailing hardware and software requirements, as well as the RS-232 protocol features. It includes step-by-step instructions for setting up the program in Keil uVision and provides source code for initializing serial communication, transmitting, and receiving data. The expected output in the UART Serial Window is 'HELLO'.

Uploaded by

viquarsultana135
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAM TO RS232 COMMUNICATION DEMONSTRATION

Aim: write a ASM program to transmission and reception of data using RS232 communication in
kileuvision.

Hardware requirements: 8051 evaluation board

Software Requirements: Kile U vision 5, Microsoft IDE, ATMEL Flip.

Description:

 RS-232 is a serial communication protocol used for transmitting and receiving data one bit at a
time over a single wire.
 It is commonly used to interface microcontrollers (e.g., 8051) with PCs, GSM modules, GPS
receivers, or other devices.
 The 8051 microcontroller uses UART (Universal Asynchronous Receiver-Transmitter) for
serial communication.

Key Features of RS-232

Feature Description

Type Asynchronous serial communication

Baud Rate Common rates: 9600, 19200, 115200 bps

Voltage Levels ±12V for RS-232 (converted to 0-5V TTL for 8051)

Wiring Uses TX (Transmit), RX (Receive), and GND (Ground)

Data Frame Start bit (1) + 8 Data bits + Parity (Optional) + Stop bit (1 or 2)

RS-232 Pin Configuration (DB9 Connector)

Pin Function 8051 Connection


2 RX (Receive) Connects to TXD (P3.1)
3 TX (Transmit) Connects to RXD (P3.0)
5 GND (Ground) Connects to GND of 8051

Note: Since RS-232 operates at ±12V, a MAX232 IC is used to convert signals to 0-5V TTL
levels.
Running the Program in Keil

1. Create a new project in Keil uVision.

2. Select the microcontroller (AT89C51/AT89S52).

3. Create a new ASM file, paste the above program, and save it as RS232_Comm.asm.

4. Add the file to Source Group 1 (Right-click Source Group → Add Files).

5. Compile the program (F7).

6. Start Debugging (Ctrl + F5).

7. Open Serial Window (View → Serial Windows → UART #1).

8. Run the code (F5).

9. Check the output in the UART Serial Window.

PROGRAM SOURCE CODE

ORG 0000H ; Start of program

//; === Serial Communication Initialization ===

MOV TMOD, #20H ; →Sets Timer 1 in Mode 2 (8-bit auto-reload mode).

MOV TH1, #0FDH ; → Loads TH1 = 0xFD (-3 in decimal) to generate Baud rate 9600 for 11.0592
MHz crystal

MOV SCON, #50H ; → Configures Serial Control Register (SCON)

SETB TR1 ; →Start Timer 1 to generate the baud rate.

//; === Transmit Data ===

MOV SBUF, #'B' ; Load character 'A' into SBUF


JNB TI, $ ; Wait for transmission to complete

CLR TI ; Clear Transmit Interrupt Flag

; === Receive Data ===

HERE: JNB RI, HERE ; Wait until data is received

MOV A, SBUF ; Move received data into A

CLR RI ; Clear Receive Interrupt Flag

SJMP HERE ; Loop infinitely

END

OUTPUT:

When you open the UART Serial Window in Keil, you should see printed in the terminal.

HELLO

You might also like