Advantech PCL-740 Spezifikationen Seite 24

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 29
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 23
Appendix A Register structure and format 21
Programming example
The following C example shows how to program the PCL-740's
registers directly. It uses I/O ports hex 3F8 and 2F8 to test the PCL-
740’s send, receive and FIFO functions.
/**************************************************/
/* Program: DEMO01.C */
/* Description: */
/* Sends a string from COM1 to COM2 then reads */
/* it back from COM2 and displays it on the */
/* screen. It uses direct register control. */
/**************************************************/
#include <dos.h>
#include <io.h>
#include <stdio.h>
#include <conio.h>
/* Timeout value in seconds */
#define TIME_OUT 10000
static int base0=0x3f8; /* Port 1 base address (COM1) */
static int base1=0x2f8; /* Port 2 base address (COM2) */
static char rec[16]; /* Receive buffer */
static char cmd[16]; /* Command buffer */
void main()
{
int i;
timeout; /* counter for timeout */
char flag;
/* Set up Port 1 (COM1) */
outport((base0+2),0xc9); /* Enable FIFO */
outp(base0+3,0x80); /* Set DLAB=1 */
/* Set bps = 115200 */
outp(base0 ,0x01); outp(base0+1,0x00);
outp(base0+3,0x03); /* set data=8; stop=1; no parity*/
outp(base0+1,0x00); /* disable interrupt */
Seitenansicht 23
1 2 ... 19 20 21 22 23 24 25 26 27 28 29

Kommentare zu diesen Handbüchern

Keine Kommentare