ATR: chpt.13: Serial Input/Output (SIO)

From: Craig Lisowski (aa853@cleveland.Freenet.Edu)
Date: 01/04/94-02:44:37 PM Z

From: aa853@cleveland.Freenet.Edu (Craig Lisowski)
Subject: ATR: chpt.13: Serial Input/Output (SIO)
Date: Tue Jan  4 14:44:37 1994

                                  CHAPTER 13
     Most input and output with the Atari computer passes through the
     serial I/O bus.  The SIO interface is rather complicated but you are
     unlikely to need to use it directly.  CIO usually handles SIO for you.
     However, if you want to design your own I/O device and it's associated
     handler, you need to know how to use the SIO.
     SIO transfers data at a rate of 19,200 baud on separate input and
     output lines.  The data is sent one byte at a time, LSB first, in an
     asynchronous format.  There are also clock-in and clock-out lines. 
     There is a signal on the clock-out line but it is not used by any
     present devices.  The clock-in line is available for synchronous
     transfer but is not used by the OS.  The signal on the clock-out line
     goes high at the leading edge of each bit and goes low in the middle
     of each bit.
                             One byte of SIO data
                    +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+
                    | | | | | | | | | | | | | | | |        clock
       -------------+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +------
       ---------+       +---+   +-------+       +--------
                |     0 | 1 | 0 | 1   1 | 0   0 | 1        data
                +-------+   +---+       +-------+
                  |                                    |
              start bit                            stop bit
     The SIO interface is used much like the resident disk handler.  In
     fact, it uses the same device control block as the resident disk
     handler.  After the control block parameters are set, a JSR is made to
     the SIO entry vector, SIOV, at $E459 (58457).
                        Device control block (for SIO)
     DDEVIC [$0300 (768)]
          Serial bus I.D.  Set by handler or program.
     DUNIT  [$0301 (769)]
          Device number if more than one.
     DCOMND [$0302 (770)]
          Device command byte.
     DSTATS [$0303 (771)]
     Before the SIO call, this byte tells whether the operation is read,
     write or that there is no data transfer associated with the command. 
     After the call this byte will hold the status (error/no error code) of
     the operation.
                         DSTATS format before command
               7 6 5 4 3 2 1 0
              |W|R| not used  |
     If both W and R are 0, there is no data transfer.
     DBUFLO [$0304 (772)]
     DBUFHI [$0305 (773)]
     Points to the data buffer for either input or output.
     DTIMLO [$0306 (774)]
     Timeout value (response time limit) in 64/60ths of a second to be set
     by handler or program.
     DBYTLO [$0308 (776)]
     DBYTHI [$0309 (777)]
     Number of bytes to be transferred, set by handler or program.  This
     parameter is not required if the DSTATS specifies no data transfer.
     DAUX1  [$030A (778)]
     DAUX2  [$030B (779)]
     These parameters are sent to the device as part of the command frame.
     All commands on the serial bus must originate from the computer.  The
     peripherals will present data on the bus only when commanded to do
     Any operation on the serial bus begins with a five byte command frame.

     While the command frame is being sent, the command line of the serial
     connector is 0.
                             Command frame format
               $xx  DDEVIC
               $xx  DCOMND
               $xx  DAUX1
               $xx  DAUX2
               $xx  checksum
     The first four bytes of the command frame come from the device control
     block.  the checksum is the sum of the other four bytes with the carry
     added back after each addition.
     If both R and W of the DSTATS are 0, no data is sent to, or expected
     from the peripheral, after a command frame is sent.  However, the
     device is usually expected to send an ACK byte ($41) after the command
     frame is sent.  If the command frame is invalid, an NAK byte ($4E)
     should be sent.
     If the operation is output (W = 1) the computer will send a data frame
     after it receives the ACK of the command frame.  It then expects an
     ACK after the data frame is sent.
     If the operation is an input (R = 1) the computer expects a data frame
     from the peripheral after the ACK.  With either input or output, a
     "complete" code ($43) should be sent to the computer when the
     operation is finished.  The "complete" code would follow the ACK of
     the data frame with an output operation.
     If the operation is not completed for some reason, the peripheral
     should send an error code ($45) instead of "complete".
                                SIO data frame
         byte 1     $xx\
                        > data bytes
         byte n     $xx/
         byte n+1   $xx   checksum
                                 SIO commands
     READ      $52
     WRITE     $57
     STATUS    $53
     PUT       $50
     FORMAT    $21
     DOWNLOAD  $20
     READADDR  $54
     READ SPIN $51
     MOTOR ON  $55
      SECTOR   $56
                           Present SIO device I.D.s
     DISK      $31 - $34  (D1 - D4)
     PRINTER   $40
     RS-232-C  $50 - $53  (R1 - R4)
     The serial connectors on the computer and all peripherials are
     identical.  Nearly all peripherials have two serial connectors. 
     Either connector may be used for any connection.  The serial bus is
     designed so that peripherials can be daisy-chained together.  The
     following is a diagram of the serial connector.
                         The serial connector pin-out
                            1 1
                    2 4 6 8 0 2
                   /o o o o o o\
                  /o o o o o o o\
                   1 3 5 7 9 1 1
                             1 3
      1  clock in (to computer)
      2  clock out
      3  data in
      4  GND
      5  data out
      6  GND
      7  command (active low)
      8  cassette motor control
      9  proceed (active low)
     10  +5V/ready
     11  audio in
     12  +12V (400/800)
     13  interrupt (active low)
     Proceed goes to pin 40 (CA1) of the PIA.  It is not used by present
     Interrupt goes to pin 18 (CB1) of the PIA.  It is not used by present
     Pin 10 doubles as a 50mA +5V peripharal power supply and a computer
     ready signal.
                   Useful database variables and OS equates
     SIOV   $E459      (58457): serial port handler entry
     DDEVIC $0300        (768): device ID
     DUNIT  $0301        (769): device number
     DCOMND $0302        (770): command byte
     DSTATS $0303        (771): status byte
     DBUFLO $0304        (772): data buffer pointer
     DBUFHI $0305        (773):
     DTIMLO $0306        (774): timout value
     DBYTLO $0308        (776): number of bytes to transfer
     DBYTHI $0309        (777):
     DAUX1  $030A        (778): sent to device
     DAUX2  $030B        (779): sent to device

Return to message index