4,2
Transmitting
and
Receiving Characters
Actual character transmission and reception may begin once
the SIB has been initialized.
A character
is
transmitted by
writing
it
to the
given USART's data
port.
When
the
USART
is
ready
to
accept another character
for
transmission,
the
TxPDY
bit
in
the
status byte comes
on.
TxRDY
is
also connected
to
the
transmit interrupt CTC
,
causing
an
interrupt
to
occur
whenever
the
USART
is
ready
to
accept another character.
Normally,
the
transmit interrupt handler does
the actual
transmission
and checks
if
there are any more characters
to
send
.
Whenever
a
given USART receives
a
character,
the
RxRDY status
bit comes
on.
Since RxRDY
is
connected
to the
receive
interrupt CTC,
the
interrupt occurs whenever
a
character
is
ready
to be read by the Z80.
After reading
a
character,
the
3
error bits
in the
status byte should
be
checked.
If
an
error occurs, an error routine should
be called.
To restart,
a
command byte with
the error reset bit (bit
4)
turned on
should
be sent,
followed by
the
original command
to
put the
USART back
into its state
previous
to the error.
If
the
USART
is
run
with
the error reset bit
turned
on and
if
the
data character
is
read before the status, no error will ever
be
detected since
the
data read will always reset any errors.
4.3
Writing Interrupt Handlers
Interrupt handlers will differ depending
on the
intended
application, but there
are
a
few general principles which
should
be
understood.
The
280
peripheral device family uses
a
hardwired daisy chain interrupt priority
scheme.
In
the
chain, the SIB has
a
priority which
is
determined
by the
backplane connections
of lEI and lEO,
Within
the SIB, each
CTC
is
ordered by channel number (lowest number has highest
priority) with receive interrupts
(CTC
1)
having higher
priority
than transmit interrupts
(CTC 2).
When
an
interrupt
occurs,
it
disables further interrupts
and
disconnects
the
daisy
chain.
An interrupt service routine must terminate by
enabling interrupts and issuing
a
RETI instruction which
reconnects
the
daisy chain.
After the RETI has been
executed,
the
highest priority pending interrupt will
be
recognized
.
The receive interrupt handler
for
a
given SIB channel needs
to read
a
character and check the USART's status.
Inputting
a
character from
a
USART turns RxRDY off
and
allows
it
to
52
Need help?
Do you have a question about the Z-80 SIB and is the answer not in the manual?
Questions and answers