Article View: comp.sys.atari.st
Article #36578Re: Mfpint()
From: Jason Blochowiak
Date: Wed, 15 Feb 1989 19:52
Date: Wed, 15 Feb 1989 19:52
58 lines
2477 bytes
2477 bytes
It's been awhile since I've dealt with the low level stuff on the ST,
but some general things:
When enabling an interrupt, you almost always initialize the vector
before you enable the interrupt. So, in this case, you'd do:
{
Mfpint(14,interrupt);
Jenabint(14);
}
Also, it makes life easier if you use the constants included in the
header files, e.g. "Mfpint(RING_INT,interrupt" (this is not a real constant,
just an example).
One possible reason for the routine bombing: You say that in your
"other" routine (we'll call it "loop()"), you "...print stuff on screen in
endless loop...". You then also try to print from within your interrupt
routine. Perhaps there's a conflict? Even if there isn't, it'd probably be
cleaner to set a flag, and then have loop() check it. So, we have:
int rings;
loop() /* Set the interrupt up & loop */
{
rings = 0; /* Initialize the ring count */
Mfpint(14,interrupt); /* Install my ring handler */
Jenabint(14); /* Enable interrupt */
for (;;) /* Loop forever */
{
if (!rings) /* If no rings, say so... */
printf("No rings...\n");
else /* Otherwise, show # of rings */
{
printf("There've been %d rings\n",rings);
rings = 0;
}
}
}
interrupt()
{
setrte(); /* MWC's function so we can rte instead of rts */
rings++; /* Increment the ring count */
}
I didn't use Cconws because I didn't feel like dealing with printing
a decimal conversion... Also, note that this code chunk doesn't deal with what
would happen if there was a ring after the printf() in the else {}, but before
the "rings = 0" statement - it would lose a ring.
I hope this helped...
------------------------------------------------------------------------------
Jason Blochowiak (blochowi@garfield.cs.wisc.edu)
"Not your average iconoclast..."
------------------------------------------------------------------------------
Technical Details
Message-ID:
<2267@puff.cs.wisc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!husc6!uwvax!puff!cat42!blochowiReferences:
<8902140121.AA03228@ucbvax.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!husc6!uwvax!puff!cat42!blochowi From: blochowi@cat42.CS.WISC.EDU (Jason Blochowiak) Newsgroups: comp.sys.atari.st Subject: Re: Mfpint() Summary: Some suggestions and a chunk of code Keywords: C, interrupts, programming Message-ID: <2267@puff.cs.wisc.edu> Date: 15 Feb 89 19:52:15 GMT References: <8902140121.AA03228@ucbvax.Berkeley.EDU> Sender: news@puff.cs.wisc.edu Reply-To: blochowi@cat42.CS.WISC.EDU (Jason Blochowiak) Organization: U of Wisconsin CS Dept Lines: 58