[net.micro.mac] Interrupts on the Mac

tgia@ur-tut.UUCP (Tony Giaccone) (05/21/86)

Hi folks,

I'm hoping that someone out there will be able to help me with a problem I'm 
having. I'm trying to bypass the serial driver and work directly with the SCC.
To this end I've written code which will allow me to read and write directly to
the SCC. I can send data out or receive it at any baud rate as long as I poll 
the SCC. Now I want to be able to use interrupts to drive my code.  However, 
I can't seem to get the interrupts to act the way I think they do, so there 
must be something I'm missing. First I'll explain how I think this mess works 
and then I'll describe what happens when I execute my code.

As I understand it there are seven levels of interrupts on the 68000. The SCC 
will interrupt using vector 2. When a level 2 interrupt occurs the PC is loaded 
with the value at location $68. The code which is executed then determines why 
the SCC interrupted the processor and does a jsr to a value located in the 
Lvl2DT table. A displacement of 24 bytes into this table holds the address of 
the code to be called if a character has been received on port a. As I 
understand it all i should have to do is load that table with the address of 
my code and set up the SCC to interrupt on receive character available.

Here's how things work now. I have TMON installed, so that I can stop the 
execution of my code at any point. In order to catch the interrupts that I'm 
interested in I replace the level 2 and 3 interrupt vectors at locations $68 
and $6c to point to my code. All my code does is jmp to the locations that 
were originally in those two vectors. I do this so that I can set break 
points at the jumps, so that every time a level 2 or 3 interrupt occurs I 
fall into TMON. I know this works because every time I move the mouse I drop
into TMON. However, when I send a character to the modem port my Mac hangs up. 
I'm at a loss to understand why this happens, any help would be appreciated.
If anyone has a section of code that does what I need that would be great.


				Thanks
					Tony Giaccone

phil@sivax.UUCP (05/23/86)

> 
> Hi folks,
> 
> I'm hoping that someone out there will be able to help me with a problem I'm 
> having. I'm trying to bypass the serial driver and work directly with the SCC.
> To this end I've written code which will allow me to read and write directly to
> the SCC. I can send data out or receive it at any baud rate as long as I poll 
> the SCC. Now I want to be able to use interrupts to drive my code.  However, 
> I can't seem to get the interrupts to act the way I think they do, so there 
> must be something I'm missing. First I'll explain how I think this mess works 
> and then I'll describe what happens when I execute my code.
> 
> As I understand it there are seven levels of interrupts on the 68000. The SCC 
> will interrupt using vector 2. When a level 2 interrupt occurs the PC is loaded 
> with the value at location $68. The code which is executed then determines why 
> the SCC interrupted the processor and does a jsr to a value located in the 
> Lvl2DT table. A displacement of 24 bytes into this table holds the address of 
> the code to be called if a character has been received on port a. As I 
> understand it all i should have to do is load that table with the address of 
> my code and set up the SCC to interrupt on receive character available.
> 
> Here's how things work now. I have TMON installed, so that I can stop the 
> execution of my code at any point. In order to catch the interrupts that I'm 
> interested in I replace the level 2 and 3 interrupt vectors at locations $68 
> and $6c to point to my code. All my code does is jmp to the locations that 
> were originally in those two vectors. I do this so that I can set break 
> points at the jumps, so that every time a level 2 or 3 interrupt occurs I 
> fall into TMON. I know this works because every time I move the mouse I drop
> into TMON. However, when I send a character to the modem port my Mac hangs up. 
> I'm at a loss to understand why this happens, any help would be appreciated.
> If anyone has a section of code that does what I need that would be great.
> 
> 
> 				Thanks
> 					Tony Giaccone

I tried to do it too, and got about as far as you did.  My program had to be
content with polling.  Using interrupt processing seems to be a little more
complicated because of the ROM drivers trying to get the interrupt anyway.

If you poll with interrupts off, it works fine.

Phil Hunt