[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read full 8-bit character from serial port (reprise)



Greetings all!

A little over a year ago I started a thread asking about reading full
8-bit characters from the Apple IIgs serial port (in 6502 mode).
Well, I'm revisiting the idea a bit.

I have things now to the point where I can *send* all 8-bit
characters, by using the "Z" command after PR#2.  Since I'm using
QForth (a small plug) I can do something like this to open the output
port after configuring it with the firmware:

: open ( -- )  (  open the output port )
  2 PR#  1 cout 90 cout ;

where cout calls the monitor COUT routine.  This works perfectly, all
256 bit patterns can be sent.

Now, for reading 8-bits.  Here I'm still stuck.  I found copies of the
IIgs hardware and firmware manuals online and have looked through
them.  That's how I finally understood the Z command, which affects
output only.

>From the last thread on this topic Jorge Chamorro Bieling posted this
code, slightly modified:

SCC_A_CMD  =  $C039   ;scc CHANNEL A
SCC_A_DATA =  $C03B
SCC_B_CMD  =  $C038   ;scc CHANNEL B
SCC_B_DATA =  $C03A
RERROR     =  $0007
STORE      =  $0006

    ORG $300

    LDA SCC_A_CMD   ;DUMMY READ TO RESET 8530 POINTER TO 0
                    ;AND TO MAKE SURE THAT WE ACCESS REGISTER 0
                    ;IN THE NEXT LINE'S LDA SCC_A_DATA
    LDX #1
    LDY #0

WAIT_RX:
    LDA SCC_A_DATA  ;READ 8530 READ REGISTER 0
    AND #$01        ;BIT 0 MEANS RX CHAR AVAILABLE
    BEQ WAIT_RX

                    ; THERE'S A CHAR IN THE 8530 RX BUFFER
    LDA #$01        ; SET THE POINTER TO 8530 RR1
    STA SCC_A_CMD
    LDA SCC_A_DATA  ; READ THE 8530 READ REGISTER 1
    AND #$70        ; D4=PARITY ERR, D5=RX BUFFER OVERFLOW
    BEQ ITS_OK      ; D6=FRAMING ERR
    JMP ERROR

ITS_OK:             ; THE RX BUFFER IS THE READ REGISTER 8
    STY RERROR
    LDA #$08        ; WE WANT TO READ THE 8530 RR8
    STA SCC_A_CMD   ; SET 8530 'POINTER' TO REGISTER 8
    LDA SCC_A_DATA  ; READ 8530'S READ REGISTER 8
    STA STORE       ; STORE THE RX CHAR SOMEWHERE
    RTS

ERROR:
    STX RERROR
    RTS

If I use this code with channel A it hangs indefinitely waiting for a
character (even if I'm sending data to the IIgs).  If I switch to
channel B, it returns immediately all the time with a 25.  I believe
channel A is the modem port, which is what I'm using.

So, quesions remain:

1.  Why doesn't this code work?  I assume I'm missing some
configuration stuff.
2.  Even if it can be made to work, it is limited to 19200 baud by the
firmware.  How do set things up to read and write using faster rates?
I want to use the IIgs as a simulator for various serial devices, most
of which talk at 38k to 115k baud.

Perhaps there is no new information out there, but from what I read
things like ADTpro for IIgs are using high serial rates.  Or,
alternatively, is it worth putting a Super Serial Card in (I do have
one)?

Any new help appreciated!

Ron