[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Read full 8-bit character from serial port (update)
- Subject: Read full 8-bit character from serial port (update)
- From: rtk <oneelkruns@hotmail.com>
- Date: Wed, 18 Jul 2007 06:49:45 -0700
- Complaints-to: groups-abuse@google.com
- Injection-info: e16g2000pri.googlegroups.com; posting-host=67.176.63.63; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
- Newsgroups: comp.sys.apple2
- Organization: http://groups.google.com
- User-agent: G2/1.0
- Xref: g2news1.google.com comp.sys.apple2:27412
Thanks to all who answered my last post on this subject, especially
for the link to the ADTpro source. I now have the Apple IIgs sending
characters, up to 57600, all 8-bits, from Forth. Reading remains an
issue, though, and I'm wondering if I'm missing a step to set that up.
For example, if I start Forth and initialize the serial port, then
attempt to wait for a character, the program hangs even when a
character is sent (FYI, I'm using either minicom or pyserial for
testing.. pyserial is a nice package if you use Python).
If I first send some characters, say, "ABC", which do appear on the
minicom screen, and then try to read I get those characters back and
then a hang waiting for something that isn't coming. For example:
0> B9600 initPort \ setup the port for 9600 baud,
8N1
0> 65 m> 66 m> 67 m> \ send "ABC", output appears on the
other computer
0> m< emit \ displays "A"
0> m< emit \ displays "B"
0> m< emit \ displays "C"
0> m< emit \ hangs waiting
Is there some buffer that needs to be cleared first? Some switch to
toggle to read a character mode?
The read/write a character parts of the ADTpro IIgs serial code are
the basis for what I'm using, virtually unchanged other than to store
the read character in a zero page location so Forth can pick it up
easily. The relevant code is here, as I'm using it, is here:
;---------------------------------------------------------
; ZCCG - Get a character from the SCC serial port (XY unchanged)
;---------------------------------------------------------
ZCCG:
LDA GSCMDB ; DUMMY READ TO RESET 8530 POINTER TO 0
pollSCC:
lda $C000
LDA GSCMDB ; READ 8530 READ REGISTER 0
AND #$01 ; BIT 0 MEANS RX CHAR AVAILABLE
cmp #$01
bne pollSCC
; THERE'S A CHAR IN THE 8530 RX BUFFER
pullIt:
LDA #$01 ; SET 'POINTER' TO rr1
STA GSCMDB
LDA GSCMDB ; READ THE 8530 READ REGISTER 1
AND #$20 ; CHECK FOR bit 5=RX OVERRUN
BEQ itsOK
ldx #$30 ; Clear Receive overrun
stx GSCMDB
ldx #$00
stx GSCMDB
itsOK:
LDA #$08 ; WE WANT TO READ rr8
STA GSCMDB ; SET 'POINTER' TO rr8
LDA GSCMDB ; READ rr8
sta $08 ; sort the character where Forth can find it
rts
I'm a bit confused by the reading from $C000, as I thought this was
used as place to clear the 80-column screen. This is why I'm thinking
there is a further step to reading characters. Also, how to clear the
output buffer, and why are characters sent still there to read?
Many questions! Any insights much appreciated. Still, this is
closer, it is fun to be able to send data at rates beyond 19200 baud.
Now, if I could just read at that rate I'd be a happy camper.
Ron