RS-232 Operation Using Turbo C
The following example shows how to program an AT personal computer
for interrupt-driven
COM
port communications. SCPI commands can be
sent to the HP 34401A and responses received for commands that query
information. The following program is written in Turbo C and can be
easily modified for use with Microsoft
Quick C.
#include <bios.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#define EVEN_7 (0x18 | 0x02 | 0x04)
/* Even parity, 7 data, 2 stop */
#define ODD_7 (0x08 | 0x02 | 0x04)
/* Odd parity, 7 data, 2 stop */
#define NONE_8 (0x00 | 0x03 | 0x04)
/* None parity, 8 data, 2 stop */
#define BAUD300 0x40
#define BAUD600 0x60
#define BAUD1200 0x80
#define BAUD2400 0xA0
#define BAUD4800 0xC0
#define BAUD9600 0xE0
/* 8250 UART Registers */
#define COM 0x3F8 /* COM1 base port address */
#define THR COM+0 /* LCR bit 7 = 0 */
#define RDR COM+0 /* LCR bit 7 = 0 */
#define IER COM+1 /* LCR bit 7 = 0 */
#define IIR COM+2 /* The rest are don’t care for bit 7 */
#define LCR COM+3
#define MCR COM+4
#define LSR COM+5
#define MSR COM+6
RS-232 Operation Using Turbo C
Microsoft is a U.S. registered trademark of Microsoft Corporation.
Continued on next page
6
Chapter 6 Application Programs
RS-232 Operation Using Turbo C
193
Summary of Contents for 34401A
Page 12: ...1 Quick Start 1 ...
Page 26: ...2 Front Panel Menu Operation 2 ...
Page 50: ...3 Features and Functions 3 ...
Page 103: ...4 Remote Interface Reference 4 ...
Page 135: ...SCPI Status System 4 Chapter 4 Remote Interface Reference The SCPI Status Model 135 ...
Page 170: ...5 Error Messages 5 ...
Page 182: ...6 Application Programs 6 ...
Page 196: ...7 Measurement Tutorial 7 ...
Page 214: ...8 Specifications 8 ...