Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!husc6!cmcl2!rutgers!uwvax!oddjob!gargoyle!ihnp4!homxb!mtuxo!tas From: tas@mtuxo.UUCP (T.SKROBALA) Newsgroups: comp.sys.amiga Subject: losing MIDI bytes Message-ID: <689@mtuxo.UUCP> Date: Mon, 7-Sep-87 13:16:25 EDT Article-I.D.: mtuxo.689 Posted: Mon Sep 7 13:16:25 1987 Date-Received: Tue, 8-Sep-87 03:10:42 EDT Distribution: comp Organization: AT&T, Middletown NJ Lines: 53 I have an application which uses serial.device to read bursts of ~400 MIDI "system exclusive" bytes, and I've had problems with occasional lost bytes, even with SERF_RAD_BOOGIE set. So I'm looking into the possibility of writing my own serial device driver. But I *still* seem to lose bytes, even with a darn-near trivial interrupt handler. Right now I have code that looks something like this: long byteCount ; main() { byteCount = 0 ; initMIDI( &byteCount ) ; getchar() ; /* wait until RETURN is hit */ printf( "%ld\n", byteCount ) ; cleanupMIDI() ; } and a serial "read buffer full" interrupt handler that is: _RBFHandler: move.w SERDATR(a0),d1 ; Copy input byte/word to d0. move.w #INTF_RBF,INTREQ(a0) ; Clear interrupt. add.l #1,(a1) ; Inc count pointed to by a1. rts I have the 1.2 operating system, 2 floppy drives, and 2 Mbytes of Fast RAM. In my tests, I do not have any background processes or other devices running unless otherwise noted. I have set the SERPER register to both 113 and 114 for 31250 bits per second. The above code, with no other processes running, will generally not lose bytes. But if I add a single process (popCLI) in the background, or if I add about 15 microseconds worth of data collection code to the interrupt handler, I start seeing data loss of 1 or more bytes per 20K (the 20K always in bursts of 400 bytes, the bursts at close to the full MIDI bandwidth of 3125 bytes per second). When I lose a byte, I usually see that the OVRUN bit has been set in the SERDATR register. Is there a bug in my simple handler? Or is there some system overhead that is occasionally locking out serial interrupts for a significantly large percentage of the 300+ microseconds between MIDI data bytes? If the latter, is there a workaround? Tom Skrobala AT&T mtuxo!tas 201-957-5446 P.S. I've had similar problems with a timer interrupt handler. I start losing 1 percent and more of my interrupts when I get above 2000 interrupts per second or so. The timer is programmed to fire repeatedly. That interrupt handler simply decrements a counter and sends a signal to the application process if the counter has gone down to 0.