Parallel To Serial Link

A past section introduced the serial port and this page presents the parallel to serial converter. Again, success under very specific circumstances most certainly does not imply a more general usefulness.

Parallel to serial converter

Had the project been built on a Monday morning, one of the output supplies would have been derived from the other. The output port may not have a high current capability, therefore the buffering transistor. The site is very fond of optoisolators, since if anything can go wrong, it will. The input and output ground are not connected, since that would defeat the issue. The output stage does not provide more than 10 mA, while an RS232 current loop specifies a typical value of 20. However, the two computers were very close to each other and the circuit managed.

The PC will terminate reception when it gets a line containing a Control-Z (decimal 26) character. For plain text this will be fine, and even for a bitmap image maybe colour 26 could be merged with a similar colour or the least often occuring colour. However, for more important data the character 26 needs to be escaped- and then the stream will have to be checked that it does not include the escape sequence naturally.

On the personal computer, the following command will do:

Copy COM1 filename

but the old board runs the following 6502 code:

Lda #128
Sta direction ; Set port MSB for output
Sei ; Disable interrupts
.back
Lda #0 
Sta port ; start bit
Jsr del
Jsr del
Ldy #8 ; Eight data bits - no parity
.more
Lsr base ; shift bit out of byte
Ror port
Jsr del
Jsr del
Dey
Bne more
Lda #128 ; stop bit
Sta port
Jsr del
Jsr del
Inc more +1; Prepare to transmit next byte
Bne back
Inc more+2
Lda more+2
Cmp #2 +(base +fileLength) Div 256 ; append Control - Z to file if need be
Bne back
Cli ; restore interrupts
Rts
.del
 Ldx delay ; 74 for 1200 baud
; This value is for the 1 MHz board only
; otherwise it must be changed, which is a serious drawback
 .still
  Dex
 Bne still
Rts

The colourspace reduction and codebook compression sections now include compiled code- at the end of the page.
1