Dual RS232 Communication Routine

with LCD display and two MAX232 for PIC16F77

Table of Contents [Toc]

Project Resources
   Available Microchip PIC Assembler Source Code

Concept   [Toc] [Top]

Two independent RS232 interfaces, with display of received ASCII characters and corresponding decimal values on the dot matrix LCD. ASCII values entered on one terminal window are transmitted by the first RS232 link to the controller, displayed on the LCD, and further transmitted across the second RS232 link to the other terminal window. The microcontroller sends feedback of received characters back to the issueing terminal window. When the PIC terminal is idle, it sends a status message '@' to both terminals every 2.75 seconds.

This program incorporates two independent RS232 interfaces, one hardware-based and one software-based. The HW-based RS232 interface uses the PIC-internal USART (and interrupts), configured to standard 9600 baud @ 4 MHz PIC clock. The SW-based RS232 interface is based on the module file m_rs096.asm, which performs interrupt-based RS232 reception on PortB0 (INTCON,INTF) at 9600 baud @ 4 MHz PIC clock.

The program shows the implementation and function of the modules m_bank.asm, m_wait.asm, m_lcd.asm, m_lcdv08.asm, and m_rs096.asm on the PIC16F77.

Dot matrix LCD display
showing output after having received 'a'  from the first RS232 terminal and 'b' from the second RS232 terminal. Every character received is displayed in both ASCII and decimal value, and then transmitted to the other RS232 terminal across the second communication link.


PIC16F77 test board with two MAX232
Test setup using onboard MAX232 and additional external MAX232 to serve both RS232 links. The PIC controller now serves two asynchronous RS232 connections, one in software mode using interrupts and one using the hardware USART of the PIC16F77.


Screen shot of the two HyperTerminal Programs
using the dual RS232 communication routine. The left window configured to ComPort 5 represents the first link, the right window configured to ComPort 7 represents the second link. After power-up and welcome message, the message 'Hello World' was entered at the left terminal window, then the message 'I say also hello' was transmitted using the right terminal window.


Specifications   [Toc] [Top]

Processor: Microchip PIC 16F77
Clock Frequency: 4 MHz crystal
Throughput: 1 MIPS
RS232 Configuration: 9600 with BRGH = 1
RS232 Baud Rate: 9600 baud, 8 bit, no parity, 1 stopbit
Code Size of entire Program: approx. 733 instruction words
Acquisition Methodology: SW-based RS232: Interrupt-based RS232 data acquisition
HW-based RS232: Preemptive, interrupt-based RS232 data acquisition,
LCD display output and RS232 echo during normal operation
Required Hardware: two MAX 232 for two RS232 interfaces, dot matrix LCD display
Required Software: RS232 terminal software (or Excel 97 RS232 Debug Interface)


Project Resources   [Toc] [Top]

Available Microchip PIC Assembler Source Code   [Toc] [Top]

Main File HEX Files
Download assembler source code:
Download Hex File:
The above program needs additional include files (modules) to get successfully assembled: m_bank.asm, m_wait.asm, m_lcd.asm
For those, who are not familiar with interfacing a PIC to the RS232 using a MAX232:   RS232-Interface.pdf   (9.7 kB)

Download ASCII Character Map: ASCII-Map.pdf


Last updated: 16.01.2005

[Toc] [Top]

If you see only this page in your browser window,
click here
to get the entire site.