[comp.sys.apple] Interrupt handling with a modem in CP/M

ianj@sactoh0 (Ian R. Justman) (07/18/89)

I need some help with writing a driver for a communications program
when using CP/M.  (I know, I know!  I'm using an archaic operating
system, but this archaic OS does a lot of things I need it to do!)
I have an Apple ][ Plus with 64k, a Microsoft SoftCard clone, a
Videx Videoterm, and a Super Serial Card driving the modem.  I
wrote an interrupt handling routine which is activated when a
character comes in and shoves the character into a circular buffer
within the driver space (it is 256 characters long, BTW...).  Even
with that in place, I still lose characters when a remote system
(say for instance, this Unix system I'm calling (I'm calling on
another computer in the house)) clears my local screen when at
1200, but I scroll ok.  However, at 2400 baud, I loose characters
during scrolling.  The actual character read occurs only during the
interrupt routine and the programs read-a-character instead of
reading the ACIA's data port, it reads what's in memory denoted by
a memory location stored in one of the Z80's register pairs
adjusted with a pointer in the Z80's base page.  I'm at a loss.
Can someone please help?

Thanks in advance.
-- 
Home:   Ian Justman       |UUCP:                 |"One of the few
6612 Whitsett Drive       |                      |die-hard CP/M
North Highlands, CA  95660| pacbell!sactoh0!ianj |addicts left on this
(916) 344-5360            |                      |planet"

brianw@microsoft.UUCP (Brian Willoughby) (07/20/89)

In article <1622@sactoh0> ianj@sactoh0 (Ian R. Justman) writes:
>I need some help with writing a driver for a communications program
>when using CP/M.  ...
>wrote an interrupt handling routine which is activated when a
>character comes in and shoves the character into a circular buffer
>within the driver space (it is 256 characters long, BTW...).  Even
>with that in place, I still lose characters ...
>-- 
>Home:   Ian Justman       |UUCP:                 |"One of the few

Try doubling the circular buffer size and rewriting the interrupt
routine.
How does the interrupt routine handle buffer full condiitions?  Are you
detecting when the buffer fills?  My interrupt routines increment a LOST
count every time a new character interrupt tries to add a character to a
full buffer.  Then, when my program is running, I can check this value
and print an error message showing how many characters were lost.  If I
see the error message, this is a sure sign that I need to increase the
buffer size for that application.

Brian Willoughby
UUCP:           ...!{tikal, sun, uunet, elwood}!microsoft!brianw
InterNet:       microsoft!brianw@uunet.UU.NET
  or:           microsoft!brianw@Sun.COM
Bitnet          brianw@microsoft.UUCP

rat@madnix.UUCP (David Douthitt) (07/23/89)

Brian Willoughby (brianw@microsoft.UUCP) wrote:
|
| In article <1622@sactoh0|  ianj@sactoh0 (Ian R. Justman) writes:
| |
| | I need some help with writing a driver for a communications program
| | when using CP/M.  ...
| | I wrote an interrupt handling routine which is activated when a
| | character comes in and shoves the character into a circular buffer
| | within the driver space (it is 256 characters long, BTW...).  Even
| | with that in place, I still lose characters ...
| 
| Try doubling the circular buffer size and rewriting the interrupt
| routine.
| How does the interrupt routine handle buffer full condiitions?  Are you
| detecting when the buffer fills?  My interrupt routines increment a LOST
| count every time a new character interrupt tries to add a character to a
| full buffer.  Then, when my program is running, I can check this value
| and print an error message showing how many characters were lost.  If I
| see the error message, this is a sure sign that I need to increase the
| buffer size for that application.

One other thing is what CP/M card you're using.  If you use the PCPI
Applicard running at 6MHz, unless I'm mistaken, the Apple's 6502 (which
handles the I/O) can't keep up with the Z80.

This trouble could also be apparent in the Microsoft Z80 card.  You
should also make sure that your interrupt handler is behaving properly:

	1]  Do you detect buffer full?

	2]  Do you detect buffer empty?

	3]  Is your interrupt handler small and fast?  .. you could
	    be losing characters due to your handler being too slow..

	4]  Are you turning interrupts off at the appropriate point?
	    .. otherwise you might have one interrupt clobbering another
	    with disastrous results..

Hope these help..

	[david]

-- 
!======= David Douthitt :::: Madison, WI =======!== The Stainless Steel Rat ==!
!  ArpaNet: madnix!rat@cs.wisc.edu              !                             !
!  UseNet: ...uwvax!astroatc!nicmad!madnix!rat  !  Mad Apple Forth:           !
!               {decvax!att}!                   !  The Madness starts here.   !