From C64-Wiki
Jump to navigationJump to search
Stub This article is very short and not very detailed. Please help to improve it.
RS232 interface for User Port

RS-232 is a communications standard developed for computers. The Commodore 64 does not have the standard implementation and needs to be adapted to communicate with standard RS-232 computers or peripherals. The decision for this was based on keeping the price of the C64 as low as possible.

RS-232 communications are handled through the User Port. Access through this port is done by POKE commands. Refer to User Port for more specific information.

C64 - RS232 interface[edit]

From HwB
 User Port C64                                           C64 RS232
                      |         |
   PA2 M-----------11-|         |-14------------------- TXD (2)
   PB1 D-----------10-|         |--7------------------- RTS (4)
   PB6 K-----------12-| MAX 232 |-13------------------- CTS (5)
 FLAG2 B---X--------9-|         |--8------------------- RXD (3)
   PB0 C---|          |         |--3--|+-|
   VCC 2-----------16-|         |--1-----|              DB25 plug
   GND N------X----15-|         |
              X--|+-2-|         |--5--|+-|
              |---------------------------------------- GND (7)

-|+- capacitor 22µF/16V
-  +

Programming in BASIC[edit]

The programming of this interface can be done in BASIC with the normal input/output commands (OPEN, CLOSE, PRINT#, CMD, GET#, INPUT#) and the system variable ST, but you must follow this things:

  • The OPEN command are set two data puffers with a large of 256 bytes (one for output and one for input) and runs automatically the CLR command (all variables are cleared!). If the program haven't less than 512 bytes variable memory (stack) free, the last part of the BASIC program is overwritting.
  • CLOSE deletes the both puffers and - also OPEN - the variable memory. If datas are in the output puffer then it will also deleted. Control before closing the data transfer if the output puffer is empty.
  • Using INPUT# isn't suggested, because by troubles hangs the program, which must be finished with RUN/STOP +RESTORE .

Example Listing

10 REM *************** control register settings
15 :
20 BR=6: REM 300 baud 
30 DB=0: REM 8 data bits (one a parity bit, see line 80) 
40 SB=0: REM 1 stop bit
45 :
50 REM *************** command register settings
55 :
60 HS=1   : REM X-wire
70 UA=0   : REM vollduplex
80 PA=160 : REM mark parity (8.databit always 1)
90 :
100 REM ************** general settings
105 :
100 LF=2 : REM logical file number (free choiceable)
110 GA=2 : REM device number of RS-232 interface
120 SA=0 : REM sekundary adress
125 :

After that you can use the following commands:


WP-W11.png Wikipedia: RS-232
WP-W11.png Wikipedia: Baud
WP-W11.png Wikipedia: V.28
WP-W11.png Wikipedia: TTL
  • DIY RS-232 Language German
  • Modern Alternative: [1] Simulant User Port to rs232 serial adapter