your mail

From: Sellam Ismail <foo_at_siconic.com>
Date: Tue Apr 10 10:21:19 2001

Ah yes, you're missing a semi-colon, silly!

:)

On Tue, 10 Apr 2001, Mekonnen Tekeste wrote:

>
> 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());
> }
>
>
>
>
>
>
>
>


Sellam Ismail Vintage Computer Festival
------------------------------------------------------------------------------
International Man of Intrigue and Danger http://www.vintage.org
Received on Tue Apr 10 2001 - 10:21:19 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:25 BST