[comp.sys.apple] INTERRUPT SERVICING

CS656@OUACCVMB.BITNET (06/22/88)

I am trying to write an interrupt driven routine to get characters from the
modem. I read incoming data fine, the problem is with outgoing. For instance,
if I type A and then type T I get TA when I type the T. Is there a way of
resetting the status register so that my keyboard interrupts don't get
reinterpreted? I'm  just assuming that that is what's happening. Is there a way
to shut off keyboard interrupts while accepting the other port 2 interrupts or
do I just have to keep sorting them out?
I've noticed that the problem only occurs if there is no input from the modem
between the keystrokes. This should be sufficient to explain the problem but
I can't make it out.
Thanks in advance
Bob Church  CS656@OUACCVMB

kamath@reed.UUCP (Sean Kamath) (06/27/88)

In article <8806220709.aa09026@SMOKE.BRL.ARPA> CS656@OUACCVMB.BITNET writes:
>I am trying to write an interrupt driven routine to get characters from the
>modem. I read incoming data fine, the problem is with outgoing. For instance,
>if I type A and then type T I get TA when I type the T.

This is either caused by getting the buffer backwards (doubtful, since ou
say it only happens when no modem input) or you aren't clearing your
interrupt signal. . . Or...

>							 Is there a way of
>resetting the status register so that my keyboard interrupts don't get
>reinterpreted? I'm  just assuming that that is what's happening. Is there a way
>to shut off keyboard interrupts while accepting the other port 2 interrupts or
>do I just have to keep sorting them out?

You don't need to shut off interrupts, just disable them while you are
performing the service routine.  I don't know what machine you are running
on, but it's got to be a GS if you have interrupts on the keyboard, or else
it's someting like the //c's built in interrupt handly, which get's a 60 Hz
interrupt and polsthe keyboard.

To clear the keyboard, you have to clear the strobe.  That shows that there
is nothing "pending".

You really should sort them out.  What you should do it this:

interrupt service routine: (assumig you aren't using ProDOS to direct them
to the right plac)

	sei 	;no interrupts
	jsr check keyboard ; was it a keyboard interrupt?
	bcs keyboard_get ; go get keyboard routine
	...	; otherwise, get input from modem.
	cli
	rti
check_keyboard ... ; keyboard routine.

Actually, after the bcs, you should then check and see if it's the modem.
If not, it's probably a transient and should be ignored (unless you are not
th only program, not a bad assumption. . . That's why prodos has it's
interrupt sevice center :-)

After getting whatever, you must clear the interrupt from wherever it came
from.  On a GS, I don' know how to do this.  On a ][, you clear the strobe
to show you already got that data.  On serial ports, you clear the status
reg. showing you got it, and it's empty.

>I've noticed that the problem only occurs if there is no input from the modem
>between the keystrokes. This should be sufficient to explain the problem but
>I can't make it out.

You neglect to actualy say on what machine it's on, how you get the
interrupt, and what type of buffer you are using, as well as how you are
currently clearing the interrupts. . . :-)

>Thanks in advance
>Bob Church  CS656@OUACCVMB

Hope this helps.

Sean Kamath

PS, if you need more info, e-mail me.

-- 
UUCP:  {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath
CSNET: reed!kamath@Tektronix.CSNET  ||  BITNET: reed!kamath@PSUVAX1.BITNET
ARPA:  reed!kamath@PSUVAX1.CS.PSU.EDU
US Snail: 3934 SE Boise, Portland, OR  97202-3126 (I hate 4 line .sigs!)