Thats pretty bizzare looking if it's for 8251 and the cmos cousin.
You sure you not talking to something else as 8251s were never 153kb/s
and I doubt the cmos parts were much faster. The addresses seems strange
but that may be an interface oddity. Also most 8251s needed a few reads
in the init after reset to clean them out.
Allison
-----Original Message-----
From: Mekonnen Tekeste <M.Tekeste(a)Bradford.ac.uk>
To: classiccmp(a)classiccmp.org <classiccmp(a)classiccmp.org>
Date: Tuesday, April 10, 2001 8:26 AM
Can Any one help me please? i am trying to interface a bar code reader
to PCI Bus via a 82C51 (UART), and i wrote a code to support my
hardware design but the software it seem wrong. Here is the code:
#include <conio.h>
#include <stdio.h>
#include <dos.h>
/* Type Definitions */
typedef unsigned char UBYTE; /* Old habbit... */
/* Serial Port Definitions */
#define STATUS 0x308 /* Status Base Address */
#define CONTROL 0x300 /* Control Base Address */
#define TXREG 0x30C /* Transmit Base Address */
#define RXREG 0x304 /* Receive Base Address */
#define TRUE 1
/* Function Prototypes */
void InitUSART(void); /* Initialize USART */
void TxData(UBYTE); /* Transmit Data */
UBYTE RxData(void); /* Receive Data */
/*
InitUSART() - Initialize USART to 153600, 8 Data Bits, No Parity, 1
Stop
Bit
*/
void InitUSART(void)
{
outp(CONTROL, 0x40); // Reset UART
outp(CONTROL, 0x4E); // Stop, no parity, 8-bit, %16 baud
outp(CONTROL, 0x05); // UART now ready
}
/*
TxData() - Send Data to Serial Port
Entry:
data = Data to transmit
*/
void TxData(UBYTE data)
{
UBYTE x;
/* Check for Tx Buffer Empty */
do
{
x = inp(STATUS);
x &= 0x01;
} while(x == 0);
outp(TXREG, data); /* Send Data */
}
/*
RxData() - Receive Data from the Serial Port
Exit:
data = Rx Data byte
*/
UBYTE RxData(void)
{
UBYTE x;
UBYTE data = 0;
while(TRUE) /* Check for Rx Data */
{
x = inp(STATUS);
x &= 0x02;
if(x == 0x02)
{
data = inp(RXREG); /* Get Data */
break;
}
/* Optional. Aborts if keypress */
if(kbhit()) /* Abort if Keypress */
{
getch();
printf("\n");
break;
}
}
return(data);
}
void main(void)
{
InitUSART();
while(TRUE)
putch(RxData());
}