Path: utzoo!attcan!uunet!mcsun!cernvax!rbt From: rbt@cernvax.UUCP (roberto divia) Newsgroups: comp.sys.m68k Subject: Re: Interrupt Handling Message-ID: <1143@cernvax.UUCP> Date: 21 Nov 89 09:08:58 GMT References: Reply-To: rbt@cernvax.UUCP (roberto divia) Distribution: comp.sys.m68k Organization: CERN European Laboratory for Particle Physics, CH-1211 Geneva, Switzerland Lines: 49 In article dleroy@x102a.harris-atd.com (leroy david 01354) writes: >I'm new to writing exception handling routines for the 68000 and have >run into severel problems. [...] > [...] When I add processing in the main loop >however, the interrupts seem to occur about 3 or 4 times and then the >processor seems to be off in the weeds somewhere. Easy and quick solution: the interrupt service routine should INCREMENT an interrupt counter and RTE, e.g.: IntE ADDQ.L #1,IntCtr ! Interrupt service routine: IntCtr must be RTE ! "imported" from C static int IntCtr = 0; ! This must be exported to ASM ... << enable interrupts >>; for (;;) { while (IntCtr != 0) { << serve the interrupt request >>; IntCtr--; } << other things >>; } You might have more then one interrupt counter. This will work fine if the interrupt doesn't require short response time. If interrupts are generated very fast and you don't mind loosing some of them, another method is the following: IntE MOVE.L #1,IntFlg ! Interrupt service routine: IntFlg must be RTE ! "imported" from C static int IntFlg = 0; ! This must be exported to ASM ... << enable interrupts >>; for (;;) { if (IntFlg != 0) { << serve the interrupt request >>; IntFlg = 0; } << other things >>; } +-----------------------+----------------------------------------------+ | Roberto Divia` | Love at first sight is one of the greatest | | ============= | labor-saving devices the world has ever seen | +-----------------------+----------------------------------------------+ | CERN : European Laboratory for Particle Physics, 1211 Geneva 23 | | Switzerland (CH) | +----------------------------------------------------------------------+