|
-
May 7th, 2003, 10:15 AM
#1
timer interrupt
i'm trying to use a timer interrupt to perform a task at a fixed period, i'm having some trouble setting the vector:
#include <stdio.h>
#include <dos.h>
#ifdef __cplusplus
#define __CPPARGGS ....
#else
#define __CPPARGS
#endif
void setup_int(void);
void interrupt isr1(__CPPARGS);
void restore(void);
void interrupt (far *old_int8_vect)(__CPPARGS);
int x = 0;
int interrupt_flag = 0;
void main() {
unsigned int i;
outportb(0x43, 0x36);
printf("square wave set");
setup_int();
for(i=0; i <= 32000; i++) {
if(interrupt_flag == 1) {
printf("INTERRUPT!");
interrupt_flag = 0;
x = 0;
} else {
printf("line: %d \n", x);
x++;
}
}
restore();
}
void setup_int(void) {
disable();
old_int8_vect = getvect(8);
setvect(8, isr1);
printf("interrupt setup");
enable();
}
void interrupt isr1(__CPPARGS) {
disable();
interrupt_flag = 1;
old_int8_vect();
enable();
}
void restore(void) {
disable();
setvect(8, old_int8_vect);
enable();
}
any comments, what's wrong with this code? eventually it's going to be used in a control system application so restoring the isr isn't really required, and messing with the clock isn't going to cause a problem.
thanks a lot
-ian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|