www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/24/05:34:16

Date: Wed, 24 Jul 1996 10:29:36 +0100 (BST)
From: Graham Sturmy <sturmyg AT cs DOT man DOT ac DOT uk>
To: boylesgj AT lion DOT cs DOT latrobe DOT edu DOT au
Cc: djgpp AT delorie DOT com
Subject: Re: ISR Interrupt handler
Message-Id: <Pine.SUN.3.91.960724102756.26442C-100000@n6k>
Mime-Version: 1.0

Some bloke (boylesgj) from another country wrote
> void interrupt KeyBoardISR(...)
> {
> 
> /* snip */
>
>  ScanCode=inportb(KeyBoardPort);
>
>  // Acknowledge the interrupt.
>  outportb(AckPort,AckValue);
>
> /* Snip snip */
>
>    sound(1000);
>    delay(50);
>    nosound();
>}

You didn't actually say what was wrong with this...
IE What do you press to make it go wrong, is it at a key on/off
Does it still appear to work but differently to how you expect
Or does it hang/reboot the machine.


One person commented that the problem might be that you called did 
  outportb(AckPort,AckValue);
at the start of the handler but I don't 'think' it matters when you do.
Might well be that you didn't mask bit 7 (Used for key off) but I think
the main problem (assuming that it hangs/reboots/does bizarre things)
might be the last 3 lines of code
    sound(1000);
    delay(50);
    nosound();
The reason this might not work is that you or only given a short time to
service interrupts and this sound and delay might make it take too long.

Try taking these lines out and trying it.
If this is the problem then do this.
  Have a play_sound variable
Instead of playing the sound in the interrupt handler set play_sound to
1 where you would have had it play.

In your main program check regularly if play_sound = 1
And play a sound if it is..
You may want to use disable() to disable the interrupt before playing
it (and enable them afterwards)

Oh yeah... And you may need to make play sound of type volatile
PS Dont forget to set play sound back to 0
(Even if the servicing time isn't the problem it might be better to change
your code to do this as it will allow more time for other interrupt
handlers to function.

Graham Sturmy (MRes course, University of Manchester, England)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019