Serial Access on a Dragon 64

A place to discuss everything Dragon related that doesn't fall into the other categories.
Post Reply
tjewell
Posts: 346
Joined: Mon Oct 19, 2009 4:58 pm
Location: Cambridge, England

Serial Access on a Dragon 64

Post by tjewell »

Don't you just hate it when you fall at the first hurdle? I'm trying to write something to the serial port on my D64. I know the port works because if I do a "POKE &HFF04,67", a letter C appears on my terminal (I've also checked with Chatview under Flex). So, inspired by Duncan's example on P337 of "Inside the Dragon", I wrote this to initialise my modem:

Code: Select all

CHARIN		EQU	$8006		; Read a character
CHAROUT		EQU  $B54A		; Write a character
SERIN		EQU	$802A		; read serial
SEROUT		EQU	$802D		; write serial
SERPORT		EQU	$FF04		; the raw port

		org	$5500

		ldx	#atcommand
writeloop	lda	,x+
		cmpa	#$00
		beq	endprog
		jsr	SEROUT
		bra	writeloop
endprog		rts

atcommand	fcc	/ATDTstuff/,$0D,$00
And, of course, when I run it, nothing happens! This is a D64 running Tormod's DLOAD ROM. What have I missed? If I replace SEROUT with CHAROUT, my code appears on the screen, so I know that's okay. It all looks okay under Xroar/GDB too (although I can't debug the serial port easily in Xroar). Utterly mystified.

Many thanks in advance!
sorchard
Posts: 530
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: Serial Access on a Dragon 64

Post by sorchard »

Hi Tony,
This is a D64 running Tormod's DLOAD ROM
The clue's in the question! ;)

The serial vectors point to RTS ops, so I guess Tormod needed the space for the drivewire stuff.

The code below is what's normally there. It's pretty small so you may as well rework for use it in your own code.

Code: Select all

*** write character to serial port (A)

BE98 3405       PSHS  CC,B
BE9A C610       LDB   #$10
BE9C F5FF05     BITB  $FF05     ;wait until TX ready
BE9F 27FB       BEQ   $BE9C     ;
BEA1 B7FF04     STA   $FF04
BEA4 3585       PULS  CC,B,PC
Stew
tjewell
Posts: 346
Joined: Mon Oct 19, 2009 4:58 pm
Location: Cambridge, England

Re: Serial Access on a Dragon 64

Post by tjewell »

Doh, I knew it would be something obvious. And I was sitting there thinking what a great environment DLOAD/Drivewire is when it's all set up, without it occurring to me it's also the problem :)

I'll move the SEROUT and SERIN ROM code into my own program, then it should run on my machine and anyone else's with a DLOAD ROM in it.

So thanks for that! Do you think we'll see you for the next Meetup? Hope we do!

Cheers, Tony
sorchard
Posts: 530
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: Serial Access on a Dragon 64

Post by sorchard »

Oh yes, I should have said I fully intend to go to this year's Meetup.

I've been keeping a low profile lately as work and family have conspired to keep me away from Dragons. Slowly getting back into it.

A big chunk of my workload is automotive, so I guess I'll be at a loose end fairly soon ;)
Stew
Post Reply