Application Notes
Appendix C
AT-DIO-32F User Manual
C-2
© National Instruments Corporation
Sending Files to be Printed
A selected disk file can be printed with the following program, which is written in C. The
program begins by prompting the user to enter the base address of the board and the name of the
file to be printed. After verifying that the file exists, the program reads characters from the file
and writes them to the port A data lines. Handshaking is automatic using the group 1 REQ and
ACK lines.
The Centronics specification requires the handshaking acknowledge signal to be a minimum of
500 nsec. This is accomplished by setting the Data Settling Delay bits in the CFG1 Register. A
500-nsec delay is sufficient for the printer to recognize communication.
/* Send a file from the PC to a Centronics printer via the
National Instruments AT-DIO-32F.
*/
#include "stdio.h"
#define CFG1offset 0x00
#define CFG2offset 0x02
#define CFG3offset 0x04
#define CFG4offset 0x14
#define STAToffset 0x00
#define PORTAoffset 0x06
int base_address, /* base_address of the AT-DIO-32F board */
cfg1, /* address of CFG1 register */
cfg2, /* address of CFG2 register */
cfg3, /* address of CFG3 register */
cfg4, /* address of CFG4 register */
tstat, /* address of STAT register */
porta; /* address of PORTA register */
FILE *fp;
FILE *fopen();
char filename[80];
main()
{
int i;
/* base_address is input from the key board */
printf("\nEnter the base_address(Hex #): ");
scanf("%x", &base_address);
printf("\nbase_address = %x(Hex)",base_address); /* echo print */
/* calculate registers address */
cfg1 = base_a CFG1offset;
cfg2 = base_a CFG2offset;
cfg3 = base_a CFG3offset;
cfg4 = base_a CFG4offset;
tstat = base_a STAToffset;
porta = base_a PORTAoffset;
Summary of Contents for AT-DIO-32F
Page 19: ......
Page 101: ......
Page 102: ......
Page 123: ......
Page 124: ......
Page 125: ......
Page 126: ......
Page 127: ......
Page 128: ......
Page 129: ......
Page 130: ......
Page 131: ......
Page 132: ......
Page 133: ......
Page 134: ......
Page 135: ......
Page 136: ......
Page 137: ......
Page 138: ......
Page 139: ......
Page 140: ......
Page 141: ......
Page 142: ......
Page 143: ......