Thread View: alt.msdos.programmer
3 messages
3 total messages
Started by Andrew Wang
Mon, 13 Apr 1992 07:44
Keyboard interrupt conflict?
Author: Andrew Wang
Date: Mon, 13 Apr 1992 07:44
Date: Mon, 13 Apr 1992 07:44
48 lines
2194 bytes
2194 bytes
Hello,
I am having a problem with keyboard interrupts crashing my
program. It is a control program with a real-time hardware interrupt
driven at 39 hz. Everything works fine until a) the keyboard buffer
fills up and the computer tries to beep or b) sometimes a single keypress
will cause it to crash.
This is what I have in my (QuickC) interrupt handler:
void _far _interrupt()
{
reset_timer(); /* Reset hardware timer for next interrupt */
clr_int(); /* Clear interrupt request from timer */
outp(8259control,0x20); /* Re-enable 8259 for next interrupt? */
_enable();
(body of interrupt handler)
}
The interrupt handler takes maybe 1 - 4 milliseconds to complete.
The program works on a 386-33, but neither of the AMI bios 486's
that we have (25,33 mhz).
Here are the things I've tried:
Removing _enable() will cause the program to crash after a certain amount
of time. This is possibly due to other interrupts not getting serviced?
Refresh?
Ignoring the keyboard entirely (not fetching any keys) will cause the
computer to crash when the buffer fills up and beeps. Quick C says never
to use INT10 to beep when the video BIOS routines are running, otherwise a
crash may occur. My main routine is very video-intensive, but I never TRY
to make the computer beep. The interrupt handler does not touch video.
Hmm, I tried some other things but now I can't remember!
Does anyone know how to disable the keyboard interrupt? I would like to try
to disable it during my interrupt handler. I'll be sure to post a follow-up
if this works!
Thanks in advance for any help you might be able to provide me!!!!
Andrew
(arrgh!)
Re: Keyboard interrupt conflict?
Author: geeslin
Date: Mon, 13 Apr 1992 21:02
Date: Mon, 13 Apr 1992 21:02
67 lines
3168 bytes
3168 bytes
In article <sbe4gINN2a9@agate.berkeley.edu>, andywang@crown.berkeley.edu (Andrew Wang) writes:
> Hello,
> I am having a problem with keyboard interrupts crashing my
> program. It is a control program with a real-time hardware interrupt
> driven at 39 hz. Everything works fine until a) the keyboard buffer
> fills up and the computer tries to beep or b) sometimes a single keypress
> will cause it to crash.
>
> This is what I have in my (QuickC) interrupt handler:
>
> void _far _interrupt()
> {
> reset_timer(); /* Reset hardware timer for next interrupt */
> clr_int(); /* Clear interrupt request from timer */
> outp(8259control,0x20); /* Re-enable 8259 for next interrupt? */
> _enable();
>
>
> (body of interrupt handler)
>
>
> }
>
> The interrupt handler takes maybe 1 - 4 milliseconds to complete.
> The program works on a 386-33, but neither of the AMI bios 486's
> that we have (25,33 mhz).
>
> Here are the things I've tried:
>
> Removing _enable() will cause the program to crash after a certain amount
> of time. This is possibly due to other interrupts not getting serviced?
> Refresh?
>
> Ignoring the keyboard entirely (not fetching any keys) will cause the
> computer to crash when the buffer fills up and beeps. Quick C says never
> to use INT10 to beep when the video BIOS routines are running, otherwise a
> crash may occur. My main routine is very video-intensive, but I never TRY
> to make the computer beep. The interrupt handler does not touch video.
>
> Hmm, I tried some other things but now I can't remember!
>
> Does anyone know how to disable the keyboard interrupt? I would like to try
> to disable it during my interrupt handler. I'll be sure to post a follow-up
> if this works!
>
> Thanks in advance for any help you might be able to provide me!!!!
>
> Andrew
> (arrgh!)
I share your frustration! I had the same problem with a
routine to do reaction times. In it, the speaker was being
driven under program control and as soon as the respondent
pressed the key (the object of the whole routine), the 486
locked up. Solution was to replace the keyboard interrupt
handler address with an address of my own choosing. Then I
could watch for a keystroke, time it, and not let the system
(the buffer) see it.
Hope this helps!
R*
--
Robert H. Geeslin, Ed.D. | Voice (918) | Department
Geeslin@VMS.OCOM.OKSTATE.EDU | 582-2681 day| of
doing EDucational Programming for 20 years | 224-0065 eve| P. and B.S.
Re: Keyboard interrupt conflict?(SOLUTION)
Author: Andrew Wang
Date: Thu, 16 Apr 1992 01:01
Date: Thu, 16 Apr 1992 01:01
76 lines
3455 bytes
3455 bytes
geeslin@vms.ocom.okstate.edu writes:
>In article <sbe4gINN2a9@agate.berkeley.edu>, andywang@crown.berkeley.edu (Andrew Wang) writes:
>> Hello,
>> I am having a problem with keyboard interrupts crashing my
>> program. It is a control program with a real-time hardware interrupt
>> driven at 39 hz. Everything works fine until a) the keyboard buffer
>> fills up and the computer tries to beep or b) sometimes a single keypress
>> will cause it to crash.
>>
> I share your frustration! I had the same problem with a
> routine to do reaction times. In it, the speaker was being
> driven under program control and as soon as the respondent
> pressed the key (the object of the whole routine), the 486
> locked up. Solution was to replace the keyboard interrupt
> handler address with an address of my own choosing. Then I
> could watch for a keystroke, time it, and not let the system
> (the buffer) see it.
> Hope this helps!
> R*
>--
>Robert H. Geeslin, Ed.D. | Voice (918) | Department
>Geeslin@VMS.OCOM.OKSTATE.EDU | 582-2681 day| of
>doing EDucational Programming for 20 years | 224-0065 eve| P. and B.S.
I'd like to thank you and the several other people who had good
suggestions to help me solve this problem!!! It sure was
frustrating, but all the help allowed me to fix it.
The twist is: The computer did not crash when the keyboard handler
interrupted my interrupt handler, but when my interrupt handler interrupted
the keyboard handler! I stripped out almost everything from my interrupt
handler (except the interrupt reset stuff) and it didn't help. I moved the
outp(control8259,EOI) instruction to the and it didn't help either.
The two scenarios which caused the crash (|as explained above) are
consistent with the diagnosios above. When the keyboard buffer filled
and the keyboard interrupt beeped, my interrupt would always
interrupt the beep and crash. Also when the keyboard interrupt was
running sometimes my interrupt would occur and cause a crash.
The solution I used (to minimize jitter in my interrupt) was:
my_timer_driven_interrupt()
{
reset_timer();
enable_timer_interrupt(); /* On Data Acquisition card */
... control routine ....
_disable(); /* 80x86 CLI */
outp(mask8259,0xFD & inp(mask8259)); /* enable keyboard intterrupt*/
_enable(); /* Now read key from keyboard */
_disable();
outp(mask8259,0x02 | inp(mask8259)); /* disable keybd int */
outp(control8259, EOI);
}
The control interrupt cannot interrupt the keyboard interrupt.
Just now, I realize if the keyboard buffer fills up and beeps,
my interrupt may try to re-enter itself! (It runs at 39 Hz).
Fortunately I have a loop counter that will spit out an error message
if that occurs.
Again, thanks for everyone's input! It was most helpful!
Andrew
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads