CODING ★ PROGRAMMING THE Z80 DART ON THE AMSTRAD ★

Programming the Z80 DART on the Amstrad
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Introduction

This File is an rewrite of my original DART.DOC file, as I have now obtained the RS data sheets for the Z80 DART. One thing this file does NOT cover is
the use of the interupt mechanisms, which seem to use port B, which on the Amstrad version is not used. Apart from that,I can now detail all the registers in the DART and their uses.

If anyone reading this disagrees with, or can expand on the information then I would be glad to hear from them so that I can make the apropriate changes to this file.

Programming

There are several values which are needed to set up a Z80 Dart so that it can communicate successfully. These are:

  1. Transmit (Tx) and Receive (Rx) baud rates
  2. Number of data bits
  3. Number of stop bits
  4. Parity
  5. Handshaking
1. Baud Rates

The baud rates are not directly programmed to the DART, but to a baud rate generator which then provides the DART with the correct timing signal. In this section, we are programming the baud rate generator (I will refer to BRG). There is a very large range of baud rates available (in theory 65536) and in computer to computer links via just the RS232 then as long as they both use the same value, the link should work without error.

However, when talking via modems, there are only a few values which are of any use, these being 2400,1200,300, and 75 (at the moment) so we need to know the right values for these data speeds. Below is a table of data speeds,with the correct value to be programed to the BRG. How to do this will be explained shortly.

Table 1

Baud rate Speed value (NB for 8253 baud rate generator)
  hs byte ls byte
31250
19200
9600
7200
4800
3600
>> 2400
2000
1800
>> 1200
600
>> 300
200
150
110
>> 75
50
45
00
00
00
00
00
00
00
00
00
00
00
01
02
03
04
06
09
0A
04
07
0D
11
1A
23
34 <<
3F
45
68 <<
D0
A0 <<
71
41
70
83 >>
C4
D9

To program to speed the baud rate generator must be told two things.
Firstly whether it is Tx or Rx rate, and secondly the speed.

The port addresses are different on the CPC and PCW range. These addresses are:

PCW CPC Port description Name used in examples
&E0
&E1
&E4
&E5
&E6
&FADC
&FADD
&FBDC
&FBDD
&FBDF
Data IO port (DART)
Data control port (DART)
Speed counter 0 (8253) (Tx)
Speed counter 1 (8252) (Rx)
Write mode word (8252)
DATPORT
CONPORT
SPED0
SPED1
WMOD

[N.B. The CPC addresses are for those interfaces conforming to the official
Amstrad specification - Amstrad, Pace, etc.]

To set Tx rate:

LD BC,WMOD
LD A,*****  ;Select clock (0036H for Tx,0076H for Rx)
OUT (C),A
LD BC,SPED0
LD A,ls byte   ;See baud rate table
OUT (C),A
LD A,hs byte   ;" " " "
OUT (C),A

To set Rx rate replace LD A,0036H with LD A,0076H and SPED0 for SPED1

-=-

From now on, all the information is being written to the Z80 DART. To program the DART, two values must be sent to the data control port. First, the
register you wish to address, then the data you wish to write. You can also input from the ports in a similar fashion.

There are 5 write registers, and 3 read. Of those, we are only interested in read registers 0 and 1, and write registers 0,3,4 and 5. (The other three are concerned with interrupts.)

First the WRITE register functions.

2) Data bits

This requires that certain bits of two of the registers are set correctly. These are registers 3 (which is Rx bit/character) and register 5 (which is Tx bit/character). Usually, these will be the same. The correct bit patterns to go in the apropriate place are:

 
bit pattern Data Bits
a b
0 0
0 1
1 0
1 1

5 per char
6 per char
7 per char
8 per char

For register 3 'a' is bit 7 and 'b' bit 6, and register 5, 'a' is bit 6 and 'b' is bit 5. As all of register 3 is set at the same time (it is not possible to set certain bits at one time, then set different ones later), I will include the other two functions of this register. Bit 0 is set to enable Rx data line, and bit 5 is set to enable Automatic handshaking using RTS and CTS. All other bits are unused but MUST be set to 0.

3) Number of stop bits and 4) Parity

These are included together as they are set at the same time. Both use register 4 as shown below.The appropriate bit settings are shown below that.

bit value use
7
6
5
4
3
2
1
0
0
1
0
0
?
?
?
?
\ Dart Clock mode (unsure of what exactly these 
/ do,but would recommend set as shown)
\ Not used 
/
\ Stop bits... 
/
\ Parity...... 
/


Bit values for Stop Bits are as follows:

bit 2 bit 3 Value
0
1
1
0
1
0
1
0
1 Stop bit
1.5 Stop bits
2 Stop bits
Illegal


Bit values for the Parity work slightly differently.

Bit 0 is set to enable Parity Checking.
Bit 1 is set for Even Parity or reset for Odd parity.

Finally I will cover the other main functions you will require.

Reset Port

This must be done to ensure no old parameters are left in the DART when you reset the values. Simply, you need only output an &18 to register 0, as all but one other function of this register is interrupt related.

Error Reset

As you will see later, the DART generates error codes, and to reset the error bits, output &38 to register 0.

Enable Port

To enable the port, you must write the appropriate values to register 5 to pull DTR and RTS high, and enable Tx line. (Also you set the Tx bit/character at the same time). The register bit allocation is as follows:

 
Bit Function
7
6
5
4
3
2
1
0
Enables DTR when high
\ Tx bits/character,(see earlier) 
/
Send break (not covered in text, but set high to enable)
Tx enable (set high to allow transmission)
Not used
Enables RTS when high
Not used

Read Registers As I said previously,we are only concerned with registers 0 and 1. The easiest way to look at each is bitwise.

Register 0
Bit Function
7
6
5
4
3
2
1
0
Rx character available (there is a character for input)
(ignore:Interrupt related)
Tx buffer empty (you can transmit a character)
DCD (Carrier detect)
RI (ring indicate) N/C in Amstrad RS232 [are you sure?]
CTS
Not used
Break received


Register 1

 
Bit Function
7
6
5
4
3
2
1
0
All sent

 | Not used 
/
Parity error
Rx overrun error
Framing error
Not used  


Actual Programming of the resgisters

To send or receive a value from one of these registers, you must first tell the DART which register you wish to address. This is done by sending the register number to CONPORT. You can then read or write a value ONCE from that register. If you wish to read it again, then you must repeat the process.

For example:

ld a,5    ;Set A reg to 5
ld bc,conport     ;Set port address
out (c),a     ;Select register 5
ld a,&ea     ;Set A reg to &ea
out (c),a    ;Write &ea to register 5

and

ld a,1    ;Set A reg to 1
ld bc,conport    ;Set port address
out (c),a    ;Select register 1
in a,(c)    ;Read contents of read register 1

*NB* The read and write registers are DIFFERENT. You cannot write a value to register 1, then read it back from register 1 as these are in fact two registers. Also, if you omit the register select, the DART will assume register 0, eg:

ld bc,conport
out (c),&18

will write &18 to register 0.

Complete set up

Finally an example on how to set up the port for a practical purpose. The port will be set for 1275 link, 1 stop bit, no parity, no handshake, 8 data bits.

LD BC,CONPORT
LD A,18H Default to register 0
OUT (C),A Reset port,pull signals low
LD A,4 Select register 4
OUT (C),A
LD A,44H 1 stop bit,no parity
OUT (C),A
LD A,3 Select register 3
OUT (C),A
LD A,0E1H 8 Data bits (handshake) (#C1=no handshake)
OUT (C),A
LD A,5 Select register 5
OUT (C),A
LD A,0EAH Enable Port
OUT (C),A

LD BC,WMOD
LD A,36H Write Tx
OUT (C),A
LD BC,SPED0
LD A,83H
OUT (C),A Set Tx
LD A,6 to 75 baud
OUT (C),A
LD BC,WMOD
LD A,76H Write Rx
OUT (C),A
LD BC,SPED1
LD A,68H
OUT (C),A Set Rx
LD A,0 to 1200 baud
OUT (C),A

I hope this information will go at least part way to allowing you to program this chip, and your RS232. When I understand the mechanisms of the interrupts used by the DART, I will update this file to include that information.


S.J.Dibble , https://CPCrulez.fr

★ YEARS: 1987 , 1988
★ AUTHOR: S.J.Dibble

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 143 millisecondes et consultée 639 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.