PC to Adapter Serial Protocol

The R8C/13 processor is connected through a serial (COM) cable to the PC. The COM port settings are:

  • 38400 Baud Rate
  • 8 Bit Data
  • One Stop Bit
  • No Parity and No Flow Control

Protocol

The flow control is solved internaly, every byte the adapter receives have to be confirmed. Data to the PC are buffered from the com driver, so no confirmation neccassary. Here are the protocol bytes:

PC -> Adpater

0 = RECEIVEDNOT USED
1 = DATAThe next byte is a data byte.
2 = DEVICE_MODESwitch the adapter into device mode (adapter works like a floppy for the real C64).
3 = COMPUTER_MODESwitch the adapter into computer mode (adapter works like a C64 for the real floppy).
4 = DEBUG_MODEThe leds on the adpter shows the IN signals.
5 = RESETReset
6 = STATUSRequest Status
7 = EOIEnd of Indicator (Last Byte)
8 = ERRORNOT USED
9 = ATN_ONSwitch ATN to ON.
10 = ATN_OFFSwitch ATN to OFF.
11 = RST_ONSwitch RST to ON.
12 = RST_OFFSwitch RST to OFF.
13 = CLK_ONNOT USED - Only in Status Response.
14 = CLK_OFFNOT USED - Only in Status Response.
15 = DTA_ONNOT USED - Only in Status Response.
16 = DTA_OFFNOT USED - Only in Status Response.
17 = DEV_ADDRSet a new device address, +1 Byte Address. (Default: 8)
18 = TIMEOUTSet the timeouts, +1 Byte Type, +1 Byte Value. (See Below)

Adpater -> PC

0 = RECEIVEDByte was received from adapter and now confirmed.
1 = DATAThe next byte is a data byte.
2 = DEVICE_MODEMode Confirmed.
3 = COMPUTER_MODEMode Confirmed.
4 = DEBUG_MODEMode Confirmed.
5 = RESETReset Confirmed
6 = STATUSStatus Response, +8 Bytes, see below.
7 = EOIEnd of Indicator (Last Byte)
8 = ERRORAn Error occurs +1 Byte Error Code, see below.
9 = ATN_ONATN switched to ON (From request or from Serial).
10 = ATN_OFFATN switched to OFF (From request or from Serial).
11 = RST_ONRST switched to ON (From request or from Serial).
12 = RST_OFFRST switched to OFF (From request or from Serial).
13 = CLK_ONNOT USED - Only in Status Response.
14 = CLK_OFFNOT USED - Only in Status Response.
15 = DTA_ONNOT USED - Only in Status Response.
16 = DTA_OFFNOT USED - Only in Status Response.
17 = DEV_ADDRNew device address confirmed, +1 Byte Address.
18 = TIMEOUTTimeout Confirmed, +1 Byte Type. (See Below)

STATUS RESPONSE

Byte 1Version (Actually 1)
Byte 2Mode (COMPUTER_MODE or DEVICE_MODE).
Byte 3Device Address (Default 8)
Byte 4Error Code (see below)
Byte 5ATN (ATN_ON or ATN_OFF)
Byte 6RST (RST_ON or RST_OFF)
Byte 7DTA (DTA_ON or DTA_OFF)
Byte 8CLK (CLK_ON or CLK_OFF)

ERROR CODES

0None
1Frame Error
2Device Not Present
3Timeout
4Error Receive Byte
5Error Ready to Send
6Error Ready to Receive
7Error Ack EOI
8Error Ack Frame
9Error Turn Sender/Receiver

TIMEOUT TYPES

0All
1Timeout TS [us] - SendByte 1 (70 us)
2Timeout TV [us] - SendByte 2 (60 us)
3Timeout TBB [us] - Time Between Bytes (100 us)
4Timeout TAT [us*10] - Ready To Send 1 (1000 us)
5Timeout TNE [us] - Ready To Send 2 (40 us)

Example

Open channel 15 on the floppy and initialize (same as OPEN 1,8,15,"I").

COMPUTER_MODE, ATN_ON, DATA, 0x28, DATA, 0xFF, ATN_OFF, EOI, DATA, 0x49, ATN_ON, DATA, 0x3F, ATN_OFF

  • 0x28 = LISTEN device 8
  • 0xFF = OPEN channel 15
  • 0x49 = "I"
  • 0x3F = UNLISTEN

Full Byte Sequence:
0x03, 0x09, 0x01, 0x28, 0x01, 0xFF, 0x0A, 0x07, 0x01, 0x49, 0x09, 0x01, 0x3F, 0x0A

Every Byte you send, a RECEIVED is returned (0x00) and optionaly a command specific response. So just send the next byte if you got a RECEIVED byte after your last send byte.