IRQ with parallel port

Hello,

I am using the parallel port’s IRQ line to measure pulses from a PWM. I have written a small piece of code that will register when a pulse is received (i.e. in the ISR registered for the parallel port’s IRQ, number 7 I believe). However, it seems I can only read one pulse, and then it stops. If I read the status port, I am then able to read as many pulses as I’d like. Here is a snippet of the code:

for( count=0; count<MAX_COUNT; count++)
{
InterruptWait( 0, NULL );
clock_cycles[count] = ClockCycles();
in8( stat_handle );
InterruptUnmask( PARALLEL_IRQ, intr_id );
}

When I remove the “in8(stat_handle)”, it no longer records more than one pulse. Anyone know why???

Thanks,
Matthew.

Because that is the nature of how interrupt works on parallel port. The interrupt needs to be clear before you can receive another one.

I thought InterruptUnmask() cleared the interrupt?

What is the difference between clearing the interrupt using the in8() function, and then clearing the interrupt using the InterruptUnmask()? I think I might be missing something, I’m fairly new to IRQs.

InterruptUnmask doesn’t clear the interrupt, it just unmask it. It’s impossible for InterruptUnmask to clear it, it would have to know about the device you are using. InterruptUNmask doesn’t talk to the parallel port it talks to interrupt controller. Every type of hardware, serial, parallel, network, A/D have different ways of clearing their interrupt.

Or imagine in the case of PCI device where there could be multiple devices on the same interrupt line. How could InterruptUnmask know which device generated the interrupt? It’s impossible.

Very good explanation, makes perfect sense to me. I was confused for a second because I found code on a site (that I thought was reputable) and they didn’t clear the interrupt by reading the parallel port, so I figured that was done through the InterruptUnmask(). But it makes sense that this function cannot know the origin of the IRQ.

Thanks.