Chapter 4
Programming
© National Instruments Corporation
4-13
PC-TIO-10 User Manual
Interrupt Programming Example for the MC6821
The PC-TIO-10 is configured so that EXTIRQ1 on the I/O connector is connected to CA1 on the
MC6821, EXTIRQ2 on the I/O connector is connected to CB1 on the MC6821, and CA2 and
CB2 of the MC6821 are disabled. The signal names CA1, CA2, CB1, and CB2 refer to the
names of pins located on the MC6821. The names are given to clarify how the interrupt circuitry
is connected on the MC6821. For more information on these signals, see Appendix D, Motorola
MC6821 Data Sheet. Interrupts are enabled and disabled through the MC6821 Control Register.
In addition, the edge that generates the interrupt is programmable through the MC6821 Control
Register.
When an interrupt is generated (as indicated when the Control Register is read), the only way the
interrupt can be cleared is by reading the Output Register (through the Data Register) of the I/O
port that indicated the interrupt. For instance, if IRQ in the Port B Control Register is set, you
must set DRS of the Port B Control Register to one, and then you must read the Port B Data
Register. The data returned may not be important depending on how you are using interrupts.
The code that follows demonstrates how to set up the MC6821 for interrupt generation.
/* defines for the program */
#define base_address 0x01A0 /* board located at address 1A0 */
#define porta_offset 0x04 /* offset for Port A */
#define portb_offset 0x06 /* offset for Port B */
#define data_offset 0x00 /* offset of Data Register */
#define ctrl_offset 0x01 /* offset of Control Register */
#define irq_channel 5 /* the interrupt channel set on W1 */
/* a sample structure for the interrupt service routine */
typedef struct { unsigned int pa_ctrl,
pa_data,
pb_ctrl,
pb_data;
int done;
} isr_block_type;
/* prototypes for the assembly language functions */
void far install_isr(int, isr_block_type far *);
void far remove_isr(void);
/* the main program */
void main()
{ unsigned int pa_ctrl,
pa_data,
pb_ctrl,
pb_data;
isr_block_type isr_block;
/* calculate register addresses */
Summary of Contents for PC-TIO-10
Page 57: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 2 National Instruments Corporation ...
Page 58: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 3 PC TIO 10 User Manual ...
Page 59: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 4 National Instruments Corporation ...
Page 60: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 5 PC TIO 10 User Manual ...
Page 61: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 6 National Instruments Corporation ...
Page 62: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 7 PC TIO 10 User Manual ...
Page 63: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 8 National Instruments Corporation ...
Page 64: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 9 PC TIO 10 User Manual ...
Page 65: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 10 National Instruments Corporation ...
Page 66: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 11 PC TIO 10 User Manual ...
Page 67: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 12 National Instruments Corporation ...
Page 68: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 13 PC TIO 10 User Manual ...
Page 69: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 14 National Instruments Corporation ...
Page 70: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 15 PC TIO 10 User Manual ...
Page 71: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 16 National Instruments Corporation ...
Page 72: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 17 PC TIO 10 User Manual ...
Page 73: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 18 National Instruments Corporation ...
Page 74: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 19 PC TIO 10 User Manual ...
Page 75: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 20 National Instruments Corporation ...
Page 76: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 21 PC TIO 10 User Manual ...
Page 77: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 22 National Instruments Corporation ...
Page 78: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 23 PC TIO 10 User Manual ...
Page 79: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 24 National Instruments Corporation ...
Page 80: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 25 PC TIO 10 User Manual ...
Page 81: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 26 National Instruments Corporation ...
Page 82: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 27 PC TIO 10 User Manual ...
Page 83: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 28 National Instruments Corporation ...
Page 84: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 29 PC TIO 10 User Manual ...
Page 85: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 30 National Instruments Corporation ...
Page 86: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 31 PC TIO 10 User Manual ...
Page 87: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 32 National Instruments Corporation ...
Page 88: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 33 PC TIO 10 User Manual ...
Page 89: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 34 National Instruments Corporation ...
Page 90: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 35 PC TIO 10 User Manual ...
Page 91: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 36 National Instruments Corporation ...
Page 92: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 37 PC TIO 10 User Manual ...
Page 93: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 38 National Instruments Corporation ...
Page 94: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 39 PC TIO 10 User Manual ...