Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Y I can't compile pass using VC++ (Serial communication)

Status
Not open for further replies.

J_expoler2

Member level 4
Joined
May 10, 2003
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
619
/* Name : Sample Comm's Program - Polled Version - termpoll.c */
/* Written By : Craig Peacock <cpeacock@senet.com.au> */
/* Date : Saturday 22nd February 1997 */

/* Copyright 1997 CRAIG PEACOCK <cpeacock@senet.com.au> */

/* See **broken link removed** */
/* For More Information */

#include <dos.h>
#include <stdio.h>
#include <conio.h>

#define PORT1 0x3F8

/* Defines Serial Ports Base Address */
/* COM1 0x3F8 */
/* COM2 0x2F8 */
/* COM3 0x3E8 */
/* COM4 0x2E8 */

void main(void)
{
int c;
int ch;
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */

/* PORT 1 - Communication Settings */

outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x03); /* Set Baud rate - Divisor Latch Low Byte */
/* Default 0x03 = 38,400 BPS */
/* 0x01 = 115,200 BPS */
/* 0x02 = 57,600 BPS */
/* 0x06 = 19,200 BPS */
/* 0x0C = 9,600 BPS */
/* 0x18 = 4,800 BPS */
/* 0x30 = 2,400 BPS */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */
outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register */
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */

printf("\nSample Comm's Program. Press ESC to quit \n");

do { c = inportb(PORT1 + 5); /* Check to see if char has been */
/* received. */
if (c & 1) {ch = inportb(PORT1); /* If so, then get Char */
printf("%c",ch);} /* Print Char to Screen */

if (kbhit()){ch = getch(); /* If key pressed, get Char */
outportb(PORT1, ch);} /* Send Char to Serial Port */

} while (ch !=27); /* Quit when ESC (ASC 27) is pressed */
}


this initial serial port ture ?? anyone can help me pls
thank
 


if you are using win 98 then inp(),_inpb(),_out(),_outb functions (instead of inport and outport)are available in conio.h so don’t need to add any lib or dll file.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top