C2N232: Commodore C2N datassette emulator with RS-232 interface

What?

The C2N232 is a small RS-232 interface that can be plugged to the
cassette port of an 8-bit Commodore computer:

PET series: 2001, 3000 series, 4000 series, 8000 series, 200 series

PET-II series: CBM 500, 600 or 700 series (P500 or the B series)

Commodore VC-20, VIC-20 or VIC-1001

Commodore 64, 4064, 64c or 64G

Commodore 128, 128D or 128DCR

Commodore 264 series: 16, 116, plus/4 or 232

In some cases, the C2N232 can be used without an RS-232 extension
cable.

Why?

The C2N232 is the first universal data transfer solution
for Commodore computers:

The device works with all 8-bit Commodores that are equipped with
a cassette interface.

The big computer can be anything that supports an RS-232
interface at 38400 bits per second and the C programming
language.

Compared to other solutions, the C2N232 is:

easy to set up (plug&play)

As the C2N232 and the accompanying software support the Commodore
cassette format, no special software needs to be loaded on the Commodore
in order to start using the interface. The PET-II series forms an exception,
since its operating system lacks cassette routines.

based on widely supported standards

RS-232 is a de facto standard, and
supported in virtually all operating systems. There is no need to write
a low-level device driver or to bypass the operating system.

Using RS-232 improves the portability on the big computer
side, as RS-232 is available on virtually all serious computers,
ranging from IBM PC compatibles to Unix workstations and big
mainframes. All software is distributed as source code, and patches
to those systems that are not yet supported are welcome.

A cassette port is available on all 8-bit Commodore computers
except the SX-64. On the 264 series, the connector is different, but
the signals are compatible.

Hardware Features

The hardware consists of only two
integrated circuits: an Atmel AT90S2313 microcontroller clocked at 8
MHz, and a Maxim MAX232 RS-232 transceiver circuit.

The RS-232 connection is electrically far more stable and safe than
connecting parallel interface chips together. Many an interface chip
could have been saved by using an RS-232 connection. Even if there
are severe grounding problems whose consequences exceed the absolute
maximum ratings of RS-232, using RS-232 will limit the damage to
easily obtainable driver chips, and not to proprietary or
no-longer-available interface circuits.

Firmware Features

The following functions have been implemented in the 128 bytes of
RAM and 1024 sixteen-bit words of program memory on the AT90S2313 in
the firmware:

Only four bytes of the 128-byte memory are reserved for the
microcontroller execution stack. Everything is interrupt-driven, and
the interrupts that drive the custom send mode may occur during RS-232
receive interrupts.

History

The idea of designing the C2N232 arised on the 30th of
June 2001, when Marko Mäkelä visited a fellow Commodore hacker in
Newcastle upon Tyne, Christopher Phillips. Christopher had no data
connection between his Commodore 64 and his main computer, an Apple
Macintosh. The only feasible interface of the Mac is RS-232, and
existing solutions that require a parallel port are clearly out of
question.

The first prototype was assembled on a Vero board in July or
August, and the software development started at the same time.

First, some code was written for reading the pulse widths of the
cassette write signal, to reverse engineer the details of the
Commodore cassette format, as the information supplied in the title
Commodore 64 Whole Memory Guide by Tim Arnot turned out to be
inaccurate. The c2n program that encodes and decodes
Commodore cassette pulses was written, and the cbmconvert
utility was enhanced with the high-level Commodore cassette
format.

Second, the function for playing back cassette pulses was
developed. There were some problems both in the hardware and in the
software. The hardware was corrected by adding a pull-up resistor on
the cassette read line. This was done on the 11th of
September 2001 when Juha Kouri and Turo Heikkinen were visiting
Marko's place in Espoo and measuring the circuit with the digital
oscilloscope Juha borrowed from his work place.

Designing the custom transfer protocol took several months due to
other activities. The protocol was designed in such a way that it
works on all 8-bit Commodores. In the idle state of the bus, both the
cassette read and write lines are on the logical high level. Both
receiving and sending is initiated by the Commodore pulling the
cassette write line low. This ensures proper operation of the
protocol even if the computer clears the input register that records
high-to-low transitions of the cassette read line. The send operation
is extremely timing-sensitive: the processor clock speed must remain
constant during it.

The digital oscilloscope was needed again in October or November
for debugging the custom transfer routines on the Commodore 264
series, whose cassette read input is level-sensitive and not
high-to-low sensitive like in all other Commodores. At that time,
nothing remarkable was reported in the news.

A prototype run of twenty C2N232 units was produced before entering
mass production. At the time of writing (22nd of May 2002),
the first unit was assembled on a professionally manufactured circuit board.
The electronic components that were ordered weeks ago will probably arrive
in June. In July, Marko will be able to deliver the first devices to eager
Commodore users.