Information Technology Reference
In-Depth Information
2
2
2
2
RD
TD
RD
TD
RD
TD
RD
TD
GND
3
3
3
3
5
5
GND
GND
GND
9-pin D-type
connector
(loopback)
9-pin D-type
connector
(loopback)
9-pin D-type
to 9-pin connection
(null modem without
handshaking)
2
2
2
2
TD
RD
TD
RD
GND
RD
TD
TD
TD
GND
3
3
3
3
7
7
5
7
GND
GND
25-pin D-type
to 25-pin connection
(null modem without
handshaking)
9-pin D-type
to 25-pin connection
(null modem without
handshaking)
Figure 13.19
System connections
Program 13.2
/*
This program transmits a character from COM1: and receives
*/
/*
it via this port. The TD is connected to RD. */
#define COM1BASE 0x3F8
#define COM2BASE 0x2F8
#define TXDATA COM1BASE
#define LCR (COM1BASE+3) /* 0x3FB line control
*/
#define LSR (COM1BASE+5) /* 0x3FD line status
*/
#include <conio.h> /* required for getch()
*/
#include <dos.h> /* */
#include <stdio.h>
/* Some ANSI C prototype definitions */
void setup_serial(void);
void send_character(int ch);
int get_character(void);
int main(void)
{
int inchar,outchar;
setup_serial();
do
{
puts("Enter char to be transmitted (Cntrl-D to end)");
outchar=getch();
send_character(outchar);
inchar=get_character();
printf("Character received was %c\n",inchar);
} while (outchar!=4);
return(0);
}
void setup_serial(void)
{
 
Search WWH ::




Custom Search