hello everyone
i am trying to interface my serial port with my project circuit but the program does not work at all.
the program works fine in turbo c version 2 and the responses from my circuit are sent to my pc via the serial port.
but when i use the same program in turbo c version 4.5 it does not work at all.
following is my c code...please help
Code:
#include <stdio.h>
#include <conio.h>
#define PORT1 0x3F8
void main(void)
{
char c,ch;
clrscr();
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x02); /* Set Baud rate - Divisor Latch Low Byte */
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 */
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("%x ",ch);
}
if (kbhit())
{
ch = getch(); /* If key pressed, get Char */
} /* Send Char to Serial Port */
} while (ch !=27); /* Quit when ESC (ASC 27) is pressed */
}