Typewriter User Manual

7- 40 MC68340 USER’S MANUAL MOTOROLA
7.4.2 Programming
The basic interface software flowchart required for operation of the serial module is shown
in Figure 7-10. The routines are divided into three categories:
Serial Module Initialization
I/O Driver
Interrupt Handling
7.4.2.1 SERIAL MODULE INITIALIZATION. The serial module initialization routines
consist of SINIT and CHCHK. SINIT is called at system initialization time to check channel
A and channel B operation. Before SINIT is called, the calling routine allocates two words
on the system stack. Upon return to the calling routine, SINIT passes information on the
system stack to reflect the status of the channels. If SINIT finds no errors in either channel
A or channel B, the respective receivers and transmitters are enabled. The CHCHK
routine performs the actual channel checks as called from the SINIT routine. When called,
SINIT places the specified channel in the local loopback mode and checks for the
following errors:
Transmitter Never Ready
Receiver Never Ready
Parity Error
Incorrect Character Received
7.4.2.2 I/O DRIVER EXAMPLE. The I/O driver routines consist of INCH, OUTCH, and
POUTCH. INCH is the terminal input character routine and gets a character from the
channel A receiver and places it in the lower byte of register D0. OUTCH is used to send
the character in the lower byte of register D0 to the channel A transmitter. POUTCH sends
the character in the lower byte of D0 to the channel B transmitter.
7.4.2.3 INTERRUPT HANDLING. The interrupt handling routine consists of SIRQ, which
is executed after the serial module generates an interrupt caused by a channel A change-
in-break (beginning of a break). SIRQ then clears the interrupt source, waits for the next
change-in-break interrupt (end of break), clears the interrupt source again, then returns
from exception processing to the system monitor.
Frees
cale Semiconductor,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...