Link to home
Start Free TrialLog in
Avatar of sky123
sky123

asked on

IRQ7 printer interrupt

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.

Please help.

Thanks :)

David

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 */

#include <conio.h>
#include <dos.h>

#define LPT_IRQ            0x0f      /* LPT1 interrupt number */
#define contr_reg      0x37a

void interrupt feedbk(void);

int i = 0;

void main()
{
unsigned char a;
void interrupt (*oldfunc)();

clrscr();
oldfunc = getvect(LPT_IRQ);  /* Save old interrupt vector */

disable();

setvect(LPT_IRQ, feedbk);  /* Install new interrupt */

/* Enable LPT1 IRQ7 */
/* Set bit 4 (IRQ) to high */
a = inportb(contr_reg);
a |= 0x10;
outportb(contr_reg, a);

enable();

while(i<10);

disable();
setvect(LPT_IRQ, oldfunc); /* Restore original interrupt */
enable();

}

void interrupt feedbk()
{
      printf("%d\n", i++);
}
ASKER CERTIFIED SOLUTION
Avatar of klos
klos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial