Appendix D Register-Level Programming
©
National Instruments Corporation
D-27
PC-DIO-96/PnP User Manual
Interrupt Programming Example for the 82C53
An in-depth example of handling interrupts generated by the 82C53 is
presented as follows. The main program is presented in C, while sample
interrupt routines are presented in assembly language.
Main() {
#define BASE_ADDRESS
0x180
/* Board located at address 180 */
#define CTR0offset
0x10
/* Offset for counter 0 */
#define CTR1offset
0x11
/* Offset for counter 1 */
#define CTRCNFGoffset
0x13
/* Offset for 82C53 CNFG */
#define IREG1offset
0x14
/* Offset for Interrupt Reg. 1 */
#define IREG2offset
0x15
/* Offset for Interrupt Reg. 2 */
#define channel
5
/* Interrupt channel selected */
#define use_ctr1
0
/* 0 for ctr0, 1 for ctr1 */
#define ctr0_data
10000
/* Pulse every 5 msec */
#define ctr1_data
1000
/* Pulse every 5 sec */
unsigned int ctr0, ctr1, cnfg, ireg1, ireg2;
/* Calculate register addresses */
ctr0 = BASE_A CTR0offset;
ctr1 = BASE_A CTR1offset;
cnfg = BASE_A CTRCNFGoffset;
ireg1 = BASE_A IREG1offset;
ireg2 = BASE_A IREG2offset;
/* Disable interrupts */
outp(ireg1,0x00);
/* Disable all 82C55A interrupts */
outp(ireg2,0x00);
/* Disable counter interrupts */
/* Set up the counter modes--do not write out the counter load values at this
time, as this starts the counter. */
outp(cnfg,0x34);
/* Set counter 0 to mode 2 */
if (use_ctr1) {
outp(cnfg,0x74);
/* Set counter 1 to mode 2 */
outp(ireg2,0x07);
/* Enable interrupts, enable counter interrupts,
and select counter 1's output */
}
else outp(ireg2, 0x06);
/* Enable interrupts, enable counter interrupts,
and select counter 0's output */
/* At this point, you should install your interrupt service routine using the
interrupt channel selected. */
/* install_isr(channel,...); */
Содержание PC-DIO-96/PnP
Страница 46: ......
Страница 47: ......
Страница 48: ......
Страница 49: ......
Страница 50: ......
Страница 51: ......
Страница 52: ......
Страница 53: ......
Страница 54: ......
Страница 55: ......
Страница 56: ......
Страница 57: ......
Страница 58: ......
Страница 59: ......
Страница 60: ......
Страница 61: ......
Страница 63: ......
Страница 64: ......
Страница 65: ......
Страница 66: ......
Страница 67: ......
Страница 68: ......
Страница 69: ......
Страница 70: ......
Страница 71: ......
Страница 72: ......
Страница 73: ......