SIO Serial Bus and Protocol
- Year
- 1979
- Type
- Interface
- Category
- Technical reference — peripheral bus
- Manufacturer
- Atari, Inc.
- Tags
- atari-inc, sio, serial-bus, pokey, pia, protocol, pinout, technical-reference, disk-drive, peripheral
Overview
Every Atari 8-bit computer from the 400 to the XE Game System talks to its disk drives, cassette recorders, printers, modems and the 850 interface through one connector: the Serial I/O (SIO) port. It is a 13-pin Atari-proprietary socket carrying a simple asynchronous serial link plus a handful of control lines. Peripherals have two identical SIO sockets, so they can be daisy-chained in any order; the cassette recorder, which has only one, goes at the end of the chain. Because every intelligent device has its own ID and answers only when addressed, a single cable from the computer can serve four drives, a printer and an interface module at once.
One plug type serves every peripheral, devices identify themselves by ID, and (from the XL OS on) a peripheral can even download its own driver software into the computer.
The connector
| Pin | Signal | Pin | Signal |
|---|---|---|---|
| 1 | Clock input (POKEY) | 8 | Motor control (PIA CA2) — cassette motor |
| 2 | Clock output (POKEY) | 9 | /Proceed (PIA CA1) |
| 3 | Data input to computer (POKEY) | 10 | +5 V / Ready (Ready only on the 1200XL) |
| 4 | Ground | 11 | Audio input (about 175 mV) |
| 5 | Data output from computer (POKEY) | 12 | +12 V on 400/800; not connected on XL/XE |
| 6 | Ground | 13 | /Interrupt (PIA CB1) |
| 7 | /Command (PIA CB2) |
The data lines go straight to POKEY's serial port, so the bus format is fixed by that chip: one start bit, eight data bits sent least-significant first, one stop bit, no parity. The standard rate is 19,200 bit/s. The computer is wired as the host (it transmits on DATA OUT and listens on DATA IN); peripherals are wired the other way round, which is why peripherals cannot normally talk to each other. Pin 11 lets a cassette's audio track, or a modem, play through the TV speaker, and pin 5 can also carry POKEY's two-tone cassette signal. Atari sold the standard SIO cable as the CX81 I/O Data Cord (5 ft).
The protocol
All intelligent devices follow the same handshake:
- Command frame. The computer pulls /COMMAND low, waits roughly 0.75–1.6 ms, and sends five bytes: device ID, command, two auxiliary bytes (for a disk, the sector number) and a checksum. It then raises /COMMAND.
- Acknowledge. The addressed device replies within about 16 ms with ACK (
$41, "A") or NAK ($4E, "N"). Devices simply ignore frames meant for someone else or with a bad checksum. - Data to the device (write-type commands only): a data frame plus checksum, which the device again ACKs or NAKs.
- Execution — from microseconds for a status request to over a minute for a disk format.
- Result. Complete (
$43, "C") or Error ($45, "E"). - Data from the device (read-type commands): the data frame and its checksum, sent even after an Error.
The checksum is an 8-bit sum with end-around carry. Neither side announces whether a command carries data, in which direction, or how long it is — both ends must already know. Some standard IDs and commands:
| ID | Device | Common commands |
|---|---|---|
$31–$3F |
Disk drives D1:… | $52 Read sector, $57 Write with verify, $50 Put (no verify), $53 Status, $21 Format |
$40 |
Printer P: | $57 Write, $53 Status |
$50–$53 |
850 serial ports R1:–R4: | |
$58 |
1030 modem T: |
The four-byte Status reply is the closest thing to a universal command; its third byte is the device's recommended timeout in units of 64 video frames. Cassettes are the exception to the whole scheme: the recorder is a "dumb" device driven only by the motor line, and the OS's cassette code records 600 bit/s FSK data instead.
Using it from software
The OS packages the protocol in the SIO routine at $E459 (SIOV). A program fills the 12-byte Device Control Block at $0300 and calls it; the result comes back in DSTATS and the Y register. Reading sector 1 of drive 1 looks like this:
LDA #$31 ; DDEVIC - disk drive bus ID
STA $0300
LDA #1 ; DUNIT - drive 1
STA $0301
LDA #$52 ; DCOMND - 'R' read sector
STA $0302
LDA #$40 ; DSTATS - $40 = data comes from device
STA $0303
LDA #<BUFFER ; DBUFLO/HI - where to put it
STA $0304
LDA #>BUFFER
STA $0305
LDA #$0F ; DTIMLO - timeout
STA $0306
LDA #128 ; DBYTLO/HI - 128-byte sector
STA $0308
LDA #0
STA $0309
LDA #1 ; DAUX1/2 - sector number 1
STA $030A
LDA #0
STA $030B
JSR $E459 ; SIOV
BMI ERROR ; Y >= 128 means an error status
Typical errors are 138 (device timeout), 139 (device NAK), 140 (framing error), 142 (overrun) and 143 (checksum error).
Polling and loadable handlers
The SIO bus can also deliver drivers. A Type 1 poll (command $3F) is how the 850 Interface Module hands its R: handler to DOS 2.0S's AUTORUN.SYS. The XL/XE OS adds Type 3 and Type 4 polls (device $4F, command $40): after boot, and whenever a program opens an unknown device name, the OS asks the bus whether any peripheral can supply a relocatable handler, then downloads it in 128-byte blocks with command $26.
Using it today / tips
- Timing is the usual problem with PC-based drive emulators. A device must ACK within about one video frame; heavily buffered USB-serial adapters can miss that, which is why SIO2PC software offers latency settings.
- Peripheral vs. host wiring. An ordinary SIO2PC cable is wired as a peripheral; to let a PC control a real Atari drive you need a reverse-wired "10502PC" cable or an auto-switching adapter.
- Power from the port. Pin 10 supplies +5 V for small devices (the XC11/XC12 recorders, the XM301 modem), but not on the 1200XL without a modification.
- High speed. POKEY's baud rate is programmable, so drive upgrades (US Doubler, Happy, Speedy), the XF551 and modern devices use faster, non-standard rates negotiated by their DOS or by a patched OS.
- Break during a write can leave a drive half-way through receiving a frame; the OS retries up to 28 times, which usually resynchronises it.
Credits
- Picture: The 13-pin SIO plug, here on the cable of an XC12 program recorder. — Multicherry, via Wikimedia Commons (CC BY-SA 4.0)
- Altirra Hardware Reference Manual — Chapter 9 (Serial I/O bus: basic protocol, poll commands) — Avery Lee (Altirra)
- comp.sys.atari.8bit FAQ (Michael Current) — 1.13, 1.15 (SIO pinout), 6.3 (CX81) — Michael Current (comp.sys.atari.8bit FAQ)
- Atari 400/800 Operating System User's Manual (1982) — serial bus devices, Appendix B/C/I/J — ksquiggle, 1982
- De Re Atari, Chapter 8 (DCB chart) — Jim Dunion (Section 8 of De Re Atari)
