[sci.electronics] Z80-SIO chip programming

andrew@kean.mun.ca (07/13/89)

Due to the large number of years between modern manufacturing procedures and my 
trusty Kaypro 10, I now find myself in a slight problem when it comes to the 
darn Z80-SIO chip.
After a _lot_ of work, I finally managed to track down a sketchy outline of the 
chip's software structure.

Can _anyone_ please tell me how to set the darn thing to 8 bits, no parity, 1 
stop, and no handshaking (if possible)?

(Bassically, all I need to know are what bytes to send to what port... Channel 
A data, Channel B Data, Chan A commands/status, or Chan B commands/status).


Thanks in advance.
-Andrew.

Bitnet: andrew@kean.mun.ca

bill@sigma.UUCP (William Swan) (07/15/89)

In article <6914@kean.mun.ca> andrew@kean.mun.ca writes:
>trusty Kaypro 10, I now find myself in a slight problem when it comes to the 
>darn Z80-SIO chip.
>After a _lot_ of work, I finally managed to track down a sketchy outline of 
>the chip's software structure.
>
>Can _anyone_ please tell me how to set the darn thing to 8 bits, no parity, 1 
>stop, and no handshaking (if possible)?
>
>Thanks in advance.  >-Andrew.  >Bitnet: andrew@kean.mun.ca


Call Zilog (408-370-8000, 210 Hacienda Ave. Campbell CA 95008-6609) for a
copy of their 1989 (yes, that's 1989) Z80 Family Data Book, which describes
the Z80-SIO.  They once had a Z80-SIO technical manual, which I recommend
highly if you can get one from them.


From what I remember of the SIO from 6-7 years back, it's not that
difficult to set up what you want. The trick is that a write to each Write
Register requires two writes: a write to WR0 which contains in its 3 LSBs
the address of the register you want to write to.

For example, to write to reg 5 you'd write out the two following bytes:
	00000101	(or xxxxx101)
	xxxxxxxx	(data for reg 5)

For what you want, the following bits are relevant (no, I can't tell you
how to select between channel A and B on the Kaypro - it's probably a
different port address):
	WR3	11xxxxx1	Rx 8 bits, enables Rx
	WR4	xxxx01x0	Rx 1 stop, no parity
	WR5	x1101xxx	Tx 8 bits, no break, enables Tx

Possibly what you're asking for is this (I believe this does no handshaking):
	WR0	00000xxx	(better check initialisation on this reg)
	WR1	xxxxxxxx	(better see how kaypro uses these)
	WR3	11000011
	WR4	ccxx01x0	cc - set for clock rate
	WR5	x1101xx0


-- 
Bill Swan  entropy.ms.washington.edu!sigma!bill  Send postal address for info:
	Innocent but in prison in Washington State for 13.5 years:
	Ms. Debbie Runyan: incarcerated 01/1989, scheduled release 07/2002.
	                   In now:  0 years,  5 months,  3 weeks,  3 days.

jimc@iscuva.ISCS.COM (Jim Cathey) (07/18/89)

Mail bounced, so here goes...

In article <6914@kean.mun.ca> andrew@kean.mun.ca writes:
>...darn Z80-SIO chip...
>Can _anyone_ please tell me how to set the darn thing to 8 bits, no parity,
>1 stop, and no handshaking (if possible)?

You must program write register 4 first in order to correctly program the SIO.
An OTIR instruction is ideally suited to the purpose of programming SIO's.

To the appropriate command port send:

	$18	; WR0: Channel reset
	$18	; Do it twice in case the part was out-of-sequence.
	$04	; WR0: Select WR4
	$44	; WR4: /16, 1 stop, no parity
	$01	; WR0: Select WR1
	$00	; WR1: No interrupts
	$03	; WR0: Select WR3
	$C1	; WR3: Rx 8 bits, No Auto Enables, Rx Enabled
	$05	; WR0: Select WR5
	$EA	; WR5: Assert DTR, Tx 8 bits, Assert RTS, Tx Enabled.

That should do it.  The SIO kicks the cookies out of most other common serial
chips for flexibility, but without a manual it's a bit hard to use!  Its only
real lack is it has no baud-rate generator.  I would take the SIO over the
265x/266x series, or that nasty 8250, or the 8251/6850 (oldies)...  The DUSCC
is a clear winner, the SCC is just an enhanced SIO, but they did change a few
things that can get you if you're not careful.

-- 
+----------------+
! II      CCCCCC !  Jim Cathey
! II  SSSSCC     !  ISC-Bunker Ramo
! II      CC     !  TAF-C8;  Spokane, WA  99220
! IISSSS  CC     !  UUCP: uunet!iscuva!jimc (jimc@iscuva.iscs.com)
! II      CCCCCC !  (509) 927-5757
+----------------+
			"With excitement like this, who is needing enemas?"