Index wersja polskawersja polska

Construction project - simple RS232 interface for the Casio PB-1000

The presented device allows to exchange files between the PB-1000 and a PC through the serial port. It isn't compatible with the original FA-7/MD-100 interface. See this project for a compatible one.

Serial port settings


circuit diagram of the RS232 interface

RS232 interface board, components sideRS232 interface board, bottom side


The programs intentionally use only a subset of instructions accepted by the built-in assembler. The HD61 assembler can be also applied, but with the LEVEL 0 option.

The timing critical parts are marked by the number of clock cycles in the comments. Please don't change them (for example by replacing the JP instructions with more optimal JR) unless you know what you are doing! - both following programs stripped of comments and excessive whitespace


The program sends the contents of the sequential file of fixed name "MEMO" through the serial port. The transfer can be interrupted with the BRK key.

        ORG     &H7000
        START   &H7000

        PST     PD,&HC4
        PST     PE,&HC0
        CAL     &HB6EE      ;copy the file name "MEMO" to WORK1
        CAL     &HE80F      ;search for a file name in WORK1, any file type
        JP      C,&HABE0    ;NF Error, file not found
        PRE     IZ,$6       ;pointer to the directory entry
        DB      233,36,96   ;= LDM $4,(IZ+$30),4
; $4,$5 = data begin pointer, $6,$7 = data end pointer
LOOP1:  SBCW    $6,$4
        RTN     Z           ;return when end of the file
        LD      $0,$30      ;keyboard column KO1
        CAL     &H0625      ;select KO column $0, read KI row to $1,$2
        BIU     $1          ;KI12 -> Carry
        RTN     C           ;return when the BRK key was pressed
        LD      $1,($4)     ;$1 <- byte to send
        ADW     $4,$30      ;increment the data pointer
        CAL     RSWRT       ;transmit the byte
        JR      LOOP1

; transmit the byte $1 through the port PD3
RSWRT:  LD      $2,&HFB     ;2 stop bits
        BIUW    $1          ;start bit
        INVW    $1
        GST     IE,$0
        PST     IE,$31      ;disable interrupts
; bit loop, should take 379 clock cycles (=910000kHz/2400baud)
RSWR1:  LD      $3,&H0C     ;12 cycles
        BIDW    $2          ;14 cycles, transmitted bit -> Carry
        ROU     $3          ;9 cycles
        BIU     $3          ;9 cycles
        BIU     $3          ;9 cycles
        BIU     $3          ;9 cycles
        PST     PE,$3       ;9 cycles
; delay
        LD      $3,11       ;12 cycles
RSWR2:  SB      $3,1        ;12 cycles
        JP      NZ,RSWR2    ;12 cycles
        NOP                 ;6 cycles
; next bit, $1,$2=&H0001 when all 11 bits have been transmitted
        SBCW    $30,$1      ;17 cycles
        JR      NZ,RSWR1    ;9 cycles
        PST     IE,$0       ;restore interrupts

Program RSREAD

The program reads data from the serial port to the sequential text file of fixed name "MEMO". The transfer is terminated upon reception of an EOF character (code &H1A), or when the BRK key was pressed, or when transmission error occurred.

Binary files can be transferred as a text (either as a list of values following the DATA statement in a BASIC program, or in the PBF hex format), then converted to the destination format. Suitable conversion programs TRANS and PBFTOBIN are provided with the HD61 assembler.

        ORG     &H7000
        START   &H7000

        PST     PE,&HC0
        CAL     &HB6EE      ;copy the file name "MEMO" to WORK1
        CAL     &HE80F      ;search for a file name in WORK1, any file type
        CAL     NC,&HE842   ;KILL, delete the file if exists
        CAL     &HB1C2      ;NDFMK, create a sequential file
        PRE     IZ,&H6945
        DB      233,2,96    ;= LDM $2,(IZ+$31),4 ;$2<-MEMEN, $4<-DATDI
        GST     IE,$1
        PST     IE,$31      ;disable interrupts
        PST     IA,$30      ;select the KO1 keyboard column
; wait for the start bit
LOOP1:  GRE     KY,$8
        BIU     $8          ;KI12 -> Carry
        JR      C,EXIT      ;return when the BRK key was pressed
; it should take ca. 1.5*379 clock cycles from this point up to BIT1
        GPO     $8          ;9 cycles
        ANC     $8,&H10     ;12 cycles
        JR      NZ,LOOP1    ;9 cycles
; start bit detected
        LDW     $8,&H0818   ;23 cycles, $9 = bit counter, $8 = delay
        JR      DEL2        ;9 cycles
; bit loop, should take 379 clock cycles from this point up to STORE
LOOP2:  NOP                 ;6 cycles
        LD      $8,14       ;12 cycles, delay
DEL2:   SB      $8,1        ;12 cycles
        JR      NZ,DEL2     ;9 cycles
; it should take 379 clock cycles from this point up to STOP1
BIT1:   GPO     $8          ;9 cycles
        AN      $8,&H10     ;12 cycles
        SBC     $30,$8      ;12 cycles, received bit -> Carry
        ROD     $6          ;9 cycles, $6 = received byte
; next bit
        SB      $9,1        ;12 cycles
        JP      NZ,LOOP2    ;12 cycles
; process the received byte
STORE:  SBC     $6,&H1A     ;12 cycles
        JR      Z,EXIT      ;9 cycles, EOF encountered
        SBCW    $2,$4       ;17 cycles
        JR      NC,OMERR    ;9 cycles, out of memory
        PRE     IX,$2       ;14 cycles
        LD      $7,&H1A     ;12 cycles, EOF character
        STW     $6,(IX-$30) ;20 cycles, store the received character + EOF
        ADW     $2,$30      ;17 cycles, increment the data pointer
        STW     $2,(IZ+$31) ;20 cycles, MEMEN
        PRE     IX,$4       ;14 cycles, DATDI
        LD      $0,3        ;12 cycles
        STW     $2,(IX+$0)  ;20 cycles, end address of the file
        LD      $8,6        ;12 cycles, delay
DEL3:   SB      $8,1        ;12 cycles
        JR      NZ,DEL3     ;9 cycles
; check the stop bit
STOP1:  GPO     $8
        AN      $8,&H10
        JR      NZ,LOOP1
FRERR:  PST     IE,$1       ;restore interrupts
        JP      &HAC30      ;FR error (framing error)
OMERR:  PST     IE,$1       ;restore interrupts
        JP      &HABBD      ;OM error (insufficient memory)
EXIT:   PST     IE,$1       ;restore interrupts

Here is a link to a similar project using an integrated interface circuit (RS232 or USB) instead of discrete components. The provided software supports data transfer speed of 9600 bps. Please note that the author chose different PB-1000 port pins.