Information Technology Reference
In-Depth Information
_outp( LCR, 0x80);
/* set up bit 7 to a 1 to set Register address bit */
_outp(TXDATA,0x0C);
_outp(TXDATA+1,0x00);
/* load TxRegister with 12, crystal frequency is 1.8432MHz
*/
_outp(LCR, 0x0A);
/* Bit pattern loaded is 00001010b, from msb to lsb these are: */
/* 0 - access TD/RD buffer , 0 - normal output
*/
/* 0 - no stick bit , 0 - even parity
*/
/* 1 - parity on, 0 - 1 stop bit
*/
/* 10 - 7 data bits
*/
}
void send_character(int ch)
{
char status;
do
{
status = _inp(LSR) & 0x40;
} while (status!=0x40);
/*repeat until Tx buffer empty ie bit 6 set*/
_outp(TXDATA,(char) ch);
}
int get_character(void)
{
int status;
do
{
status = _inp(LSR) & 0x01;
} while (status!=0x01);
/* Repeat until bit 1 in LSR is set */
return( (int)_inp(TXDATA));
}
Program 13.3
/* send.c */
#define TXDATA 0x3F8
#define LSR 0x3FD
#define LCR 0x3FB
#include <stdio.h>
#include <conio.h> /* included for getch */
#include <dos.h>
void setup_serial(void);
void send_character(int ch);
int main(void)
{
int ch;
puts("Transmitter program. Please enter text (Cntl-D to end)");
setup_serial();
do
{
ch=getche();
send_character(ch);
Search WWH ::




Custom Search