Amstrad CPC Serial Interface User Guide
Amstrad CPC Serial Interface User Guide
Amstrad CPC Serial Interface User Guide
a USIfAC)
User‟s Guide v1.5
(John Konstantopoulos, July 2019)
Table of contents
Introduction .............................................................................................. 2
Basic Usage ............................................................................................... 5
Send & Receive bytes: .............................................................................................5
Send & Receive bytes with a WiFi module acting as TCP server: ...............................6
Configure Interface ................................................................................... 7
Windows PC Communication Utility .......................................................... 8
“Terminal” Function .............................................................................................. 10
“File Copy to CPC” Function ................................................................................... 12
“File Copy From CPC” Function .............................................................................. 14
“Image Copy” Function .......................................................................................... 15
“Direct Load” Function .......................................................................................... 17
Serial Interface Utility Disk ...................................................................... 19
Configure Bluetooth Module ................................................................... 20
Configure ESP8266 WiFi Module ............................................................. 21
Do it Yourself .......................................................................................... 23
Introduction
Amstrad CPC serial interface is a universal serial port, based on the 8bit PIC
16F1579@32Mhz microcontroller. It can buffer up to 920 bytes of received data, and can
achieve speeds up to 576000bps, using a usb2serial cable adapter, or 460800bps using
a Bluetooth or Wifi Module. It is also equipped with a reset button and a Pause switch for
Amstrad CPC:
You can connect it directly to an external port raiser adapter like MX4 board:
All of these, are very easy to find on ebay and they cost almost nothing!(usb2serial can
be found at ~1euro…).
Serial interface can be used with:
- A direct serial cable connection using a usb2serial cable adapter.(Connect ONLY
Tx=Green, Rx=White, and Ground=black to serial interface pins, red cable MUST
NOT be connected to the 5V=Red)
- A wireless connection using a Bluetooth module for direct wireless connection to
a Laptop/Note book/Smart phone equipped with Bluetooth, or, two Bluetooth
modules, one connected to CPC serial interface, and the other to a usb2serial cable
adapter connected to a usb port.
- A wireless connection using an ESP-8266 wifi module! This is especially useful for
creating a LAN or for direct connection to internet!
- If you have an on old motherboard with on board RS232 serial port, you can‟t use it
directly to connect with serial interface, but you must use an RS232 to TTL
converter between them.
Basic Usage
Interface usage, is pretty simple and straight forward. Communication with the device is
accomplished using only two ports:
&FBD1: The control port
&FBD0: The data port
And the two BASIC commands INP() for receive and OUT for send.
This method can be used with direct serial/ Bluetooth module and also, WiFi module,
which must be pre-configured using the “Setwifi” program, in order to establish a
passthrough/transparent transmission mode.
To receive a byte, you must first check if there is any byte available at the buffer, by
reading the control port. Use the BASIC command: INP(&FBD1). If it returns „255‟, there
is a byte available, if not, it returns „1‟.So, in order to receive a byte from serial port, you
just give the BASIC command:
And if you want to wait until a byte is available, you can use a small loop like:
WHILE INP(&FBD1)=1:WEND
A=INP(&FBD0)
And here is the assembly code for doing the same thing:
check_BYTE:
LD A,&FB
iN A,(&D1)
DEC A
JR Z,check_BYTE
ld a ,&FB
in a,(&D0)
In order to send data using a WiFi module that is configured as TCP server (using the
“setservr” program), you must first execute an AT command:
AT+CIPSEND=0,X
Where X, is the length of the string to be sent. Data string follows immediately after.
Below is the BASIC routine to send a string of chars/bytes (named A$):
Receiving a byte/char, is done like with serial connection, BUT before getting the actual
data, there is always a header in the form of:
+IPD,1,X:
2: Enables a special “asynchronous burst” mode, for fast receiving the hole receive
buffer (920 bytes) at once. When this mode is enabled, you don‟t use INP(&FBD1) to
check if there is available byte, but instead you receive directly data using only
INP(&FBD0). When the receive buffer becomes empty, next INP(&FBD0) will cause
automatically refilling of the receive buffer (e.g. 920bytes). This mode is used in the file
transfer utility, in order to avoid asking if there is a byte available for every byte to
receive. USE WITH CAUTION, because it will freeze Amstrad, until the receive buffer is
full (920bytes)!
I have developed a utility for PC with windows, that allows communication with Amstrad
CPC:
On Amstrad CPC, run “Terminal.BAS” program. First set Serial (for cable or Bluetooth)
or Wifi module usage:
If you have selected WiFi mode and the module is not connected, you will be asked to
give Access point‟s ssid/password (this will be omitted if module is already connected to
an A.P.), and then TCP server‟s ip and port (these are obtained from groupbox “WiFi
Settings”, in PC utility program window.
On the left side, write anything, and by pressing <Return> it will be transmitted to PC.
On the right side you will receive any respond from the PC.
With terminal, you can also communicate with serial interface by sending various
commands to change port speed, clear receive buffer, get status etc. By pressing
<Enter> (or <COPY> on WiFi mode), you will get a list of all available commands.
Commands are sent by pressing <Tab> and then the desired code.
On PC side, after setting and enabling connection, select Terminal function. You can
use the edit box on the left of the <Send> button to write a message and by pressing
Send button it will be transmitted to Amstrad CPC.
“File Copy to CPC” Function
On Amstrad CPC, run “PC2CPC.BAS”. You need to set the serial port speed (for WiFi
mode, don‟t forget to run first “SetWifi” program to establish the connection) , and then,
you should get a “waiting for file…” message on screen:
After finishing transferring the files you want, you can reset Amstrad to exit the program.
“File Copy From CPC” Function
On PC, after setting and enabling connection, select “File copy From CPC” function.
Use the “Set Save Dir” button, to set the save directory for the files transferred from
CPC. On Amstrad CPC, run “CPC2PC.BAS. After setting serial speed, you will get a
files catalogue of the inserted floppy disk:
Use arrows to move between files, <space> to select/unselect a file, and <Return> to
execute transfers of the selected files. By pressing <1>, you will receive DRIVE A file
catalogue and by <2> , DRIVE B file catalogue.
Finally, with <Caps Lock> you can select/unselect all the files. This is useful if you want
to transfer all files of the disk, or if you want to “invert” the already selected files (e.g. all
selected files will be unselected, and all other, will be selected).
On the half bottom of the screen, you will get a list of all the selected files. Files from this
list, will be removed one by one, during the transfer process:
“Image Copy” Function
On PC utility program, select ”Image copy to CPC” function. Press “Select Image”
button to choose a dsk image. You will get a confirmation that image is loaded
successfully:
If you select a non Amsdos image (usually copy protected games) you will by notified
that currently these images are not supported:
Now, run the “DSK2DISK.BAS” program on the CPC, and after setting serial speed, you
will get a message to insert a disk:
By pressing any key, the transfer of the selected image will begin. Using serial speed of
460800bps or more, it should take less than a minute (~55-56seconds) to transfer a hole
180Kb disk image into any disk (either CPC/ PC/Apple formatted or unformatted).
Now, as you might already noticed, there is also a “Fast Copy” check box, right next to
Select image button. By checking this, you can transfer an image to an already
Amstrad Formatted disk in just ~40 seconds! If you check “Fast Copy”, you will be
notified, for the format type needed (in most cases is Data Format) on the disk:
This can be proved very useful if you already transfer a game image to a disk, and you
want to transfer another image on the same disk.
“Direct Load” Function
(This function works only in serial/Bluetooth mode)
By selecting the Direct Load function, you will be able to load or run a program (either
BASIC or BINARY) and also many games, directly from the PC!
The hole Procedure is rather easy and fast:
First, run the windows application and set function to “Direct Load” (com speed will be
automatically set to 115200). Then, type and save this small BASIC listing to your
Amstrad CPC:
Run the program, and after a couple of seconds, you will get the “Ready” prompt.
From now on, any LOAD” or RUN” command you will give, it will be redirected to PC!
Using button “Direct Load Dir”, you can set the loading directory and have a list of all
available files in it:
By setting loading directory to Amstrad Utility Disk folder, you can direct execute utilities
WITHOUT needing first to transfer the utility disk image to a real disk (or to a usb
stick if you have a gotek/hxc drive)!
For example, you can simply give:
Using this, you can easily extract multiple dsk images instantly!
Finally, a couple of useful notes about Direct Load function usage:
The small Basic program is needed to be executed, every time you want to load/run
a new program/game. So it could be useful to save it on a disk or tape for easy
reloading.
After initial execution of BASIC program, you can try to reload the code (after
resetting for loading another game/program), by just giving a: CALL &A9B0 at
BASIC prompt. This surely works for all BASIC programs and many simple single file
games, and also with some mutli-file games too. If this doesn‟t work (Amstrad resets
or crashes), you can reset Amstrad and run the small Basic program again.
If you try to run/load a file that it doesn‟t exist, Amstrad will hang. In this case, just
reset Amstrad, and give CALL &A9B0 at BASIC prompt.
For loading files with “.BIN” extension, this can be omitted (e.g. you can
type:RUN”GAME”, instead of:RUN”GAME.BIN”, regardless of the file having the
“BIN” extension or not). But you must include extension to load any “.BAS” files.
If, after initial running of the small basic program, you have any problem loading a
game/program, try to turn off/on Amstrad, and if this don‟t work, go to PC program
and select momentarily another function (like “terminal”) and then set to “Direct Load”
again (this will reinitialize the PC routine in case it has hang/crash).
Along with the serial interface, a dsk image is also provided, containing many useful
utilities:
Some of the above programs, have also binary “.BIN” files containing the assembly
routines for the various utilities, while “.ASM” files are ASCII text files, containing the
assembly source code (can be directly used with Maxam assembler).
If you want to develop your own applications and programs, the ASM files are very
useful for showing how to utilize the interface using assembly code, while the
Terminal program, is a good example for BASIC programs.
Configure Bluetooth Module
You could also use the HC-06 which is a bit cheaper, but it lucks the Set-Up button,
which is very useful, if you want to change the default speed of the module (9600bps).
You can easily find these on ebay or electronics shops for a few euros.
Of course you will need a pair of these, to establish a bluetooth connection between
Amstrad CPC and a PC or another Amstrad CPC. Or, you can use only one module for
Amstrad CPC serial interface to connect with a tablet or a smart phone! ;-)
Connect Bluetooth module to the USB2Serial adapter cable (Red:5V, Black:Ground,
Green:Tx-goes to Rx pin, White:Rx goes to Tx pin). Then, connect cable‟s usb plug to a
free usb port of your PC, WHILE pressing the setup button. The red led should flash
every 2-3 seconds. Now, you can easily configure Bluetooth modules using a terminal
program or even the PC communication utility I have developed.
Esp-07 or Esp-01/01S
The latter, will also need this 5v adapter (ESP-01 adapter):
You can easily find any of these, on ebay or many electronics shops, at very cheap
prices, of only a few euros. And remember to connect Tx to serial‟s interface Tx pin, and
Rx to Rx pin (no swap of signals needed).
Now, in order to use WiFi, module must be connected to an Access point and then
connect to the TCP server that is activated by the PC utility program. This can be done
either using terminal utility to give the appropriate AT commands, or more easily, by
using the small utility program “SetWiFi.BAS” provided on Amstrad CPC Serial
Interface utility disk.
First select the speed 115200 (which is usually the default speed of Wifi module) and
then, the new desired speed (up to 460800).
Then, you just give the name and password of the access point (where WiFi module will
be connected to),and then the ip address and port of the TCP server ,taken from
groupbox “WiFi Settings” in PC utility window program.
If everything goes well, you will get a “connected!” message, and then you can directly
run and use any utility you want. If there is a problem connecting to the given Access
Point or TCP server, you will be prompted for retrying or give new settings.
If for any reason you want to change TCP server‟s port number, you can do it from
“Wifi Settings” group box, (you will have to close and reopen the PC utility for
activating the new port setting) .
Note also that, when a WiFi Connection is established, the Connection button will be
automatically enabled and connection type will be set to: “Connection:WiFi”. You can
also have a serial connection and a WiFi connection both activated at the same time and
select which one to use by pressing the connection type button.
In order to disable WiFi module connection you must first send a single string of: “+++”
(check AT+CIPMODE command bellow) and then give the AT command:
“AT+CIPCLOSE” to disconnect from TCP server.
ESP8266 module use AT commands for control and communication.
You can give all AT commands using terminal program, or directly, using this small
BASIC program (a$ is the AT command string):
Note that after giving the AT command, an: out &fbd0,13:out &fbd0,10 (CR and line
feed) must be also sent for proper execution!
There is a very big manual with 100‟s of commands available, but bellow, i give you
the most useful commands, for configuring the module manually:
For more detailed information and examples, you can refer to the AT command manual
mentioned above.
Do it Yourself
You can find everything you need to make the adapter yourself, here. It contains, the
circuit diagram,the bill of materials, the gerber files for the pcb, the Pic 16F1579
microcontroller Hex file (you will need a pickit2/3 in order to flash it into PIC 16F1579),
Amstrad‟s utility dsk image disk (you can transfer it to a real disk using
CPCDISKXP),and of course the PC utility program.