Access PCI-COM422/4 user manual Sample Programs, Windows Programming, Initialization

Page 21

Chapter 5: Programming

Sample Programs

There are sample programs provided with the PCI-COM422/4 card in C, Pascal, QuickBASIC, and several Windows languages. DOS samples are located in the DOS directory and Windows samples are located in the WIN32 directory.

Windows Programming

The PCI-COM422/4 card installs into Windows as COM ports. Thus the Windows standard API functions can be used. In particular:

?CreateFile() and CloseHandle() for opening and closing a port.

?SetupComm(), SetCommTimeouts(), GetCommState(), and SetCommState() to set and change a port’s settings.

?ReadFile() and WriteFile() for accessing a port.

See the documentation for your chosen language for details.

Under DOS, the process is very different. The remainder of this chapter describes DOS programming.

Initialization

Initializing the chip requires knowledge of the UART's register set. The first step is to set the baud rate divisor. You do this by first setting the DLAB (Divisor Latch Access Bit) high. This bit is Bit

7 at Base Address +3. In C code, the call would be:

outportb(BASEADDR +3,0x80);

You then load the divisor into Base Address +0 (low byte) and Base Address +1 (high byte). The following equation defines the relationship between baud rate and divisor:

desired baud rate = (UART clock frequency) / (32 * divisor)

Manual MPCICOM422-4.E1b

Page 5-1

Image 21
Contents Model PCI-COM422/4 Page Page Terms and Conditions WarrantyCoverage Equipment Not Manufactured by AccesTable of Contents List of Tables List of FiguresCommunication Mode RS422 Balanced Mode OperationIntroduction COM Port CompatibilityBaud Rate Ranges SpecificationsCommunications Interface Environmental1PCI-COM422/4 Block Diagram Only One Serial Channel Shown PCI-COM422/4 Manual Manual MPCICOM422-4.E1b CD Installation InstallationInch Diskette Installation DOS/WIN3.xWinRisc.exe Directories Created on the Hard DiskPCIFind.exe SamplesInstalling the Card Input/Output Connections PCI-COM422/4 Manual Manual MPCICOM422-4.E1b Option Selection Data Cable WiringTerminations Baud Rate RangesSerial2 Subkey Interrupts2PCI-COM422/4 Option Selection Map Address Selection Sample Programs ProgrammingWindows Programming InitializationBaud Rate Divisor Max Diff. Cable Length Reception Transmission Connector Pin Assignments PCI-COM422/4 Manual Manual MPCICOM422-4.E1b Customer Comments