I'm currently doing a project which needs to interface the PC's parallel port to a motor. The motor's optocoupler is connected to pin 10 (ACK pin) of the parallel port. This optocoupler outputs square waves, which is a measure of the motor's speed.
When there's a voltage transition, IRQ7 will be executed. Now, the problem is how to write a handler for IRQ7. When IRQ7 is asserted, how do I tell it to execute my own interrupt handler for IRQ7.
My rough program is as shown below, but it can't work!
/* Test IRQ (ACK pin 10) of the parallel port LPT1 */
/* The optocoupler's output is connected to pin 10 */
/* A high to low transition will assert IRQ7, print value of i, and increase i */
#define LPT_IRQ 0x0f /* LPT1 interrupt number */
#define contr_reg 0x37a
void interrupt feedbk(void);
int i = 0;
unsigned char a;
void interrupt (*oldfunc)();
oldfunc = getvect(LPT_IRQ); /* Save old interrupt vector */
setvect(LPT_IRQ, feedbk); /* Install new interrupt */
/* Enable LPT1 IRQ7 */
/* Set bit 4 (IRQ) to high */
a = inportb(contr_reg);
a |= 0x10;
setvect(LPT_IRQ, oldfunc); /* Restore original interrupt */
void interrupt feedbk()