User`s manual

BL1600 System Development s 57
Direct Programming of the Serial Ports
If you are planning to use the serial ports extensively, or if you intend to
use synchronous communication, Z-World recommends that you obtain
copies of the Zilog technical manuals, available from Zilog, Inc., in
Campbell, California. You will need the Z180 MPU Users Manual and
the Z180 SIO Microprocessor Family Users Manual (which describes
the CPU and CTC, DMA, PIO and SIO functions). Z-World provides two
low-level utility functions to get you started.
int sysclock()
int z180baud( int clock, int baud )
The sysclock function returns the clock frequency in multiples of
1200bps as read from the EEPROM. The clock frequency was stored at
location 108H at the factory. The z180baud return value is an integer
whose least significant byte is stored in CNTLB0 or CNTLB1, considering
only the bits needed to set the baud rate. You must supply the clock and
baud rate in multiples of 1200 Hz. Thus, a 9.216 MHz clock is expressed
by 7680 and 19,200 bps is represented by 16. The return value is 1 if the
baud value cannot be derived from the given clock frequency.
Each serial port appears to the CPU as a set of registers. You can access
each serial port directly with the inport and outport library functions,
using the symbolic constants for addresses 0x000x09.
The symbolic constants for addresses 0x000x09 are listed in
Table G-3, Appendix G., Memory, I/O Map, and Interrupt
Vectors.
The following sample code shows how to read and write from Z180 Port 0.
char ch;
ch = inport( RDR0 );
outport( TDR0, ch );
Ports may be polled or interrupt-driven. The interrupt vectors are
SER0_VEC for Z180 Port 0, and SER1_VEC for Z180 Port 1.
Appendix G, Memory, I/O Map, and Interrupt Vectors,
provides further information about interrupt vectors.
Attainable Baud Rates
The serial ports built into the Z180 can generate standard baud rates with a
9.216 MHz clock. (The crystal is 18.432 MHz.)
$
$