[Coco] No HALT floppy IO (was Questions about the 502 controller vs theDisto SCII)
Warren Hoslet
dermunda at hotmail.com
Sat Jul 29 01:23:37 EDT 2006
>>I implemented a read routine that works (with limited testing) on a CoCo
>>2 with an FD-501. You just have to monitor the DRQ bit in the status
>>register ($FF48) to know when a byte is available. The trick is that
>>after a certian number of cycles have elapsed without a DRQ, you must
>>assume the transfer is complete and stop testing the status register so
>>that you don't clear the INTRQ request when it comes. Below is just the
>>read loop portion of my routine. The DP register is set to $FF, and B
>>contains the mask for the DRQ status bit.
> On read, yes, this does work. It's on write that we can't get it to
>fully keep up. I believe myself, Robert Gault and Alan Dekok all tried,
>and we just couldn't quite make it.
Well, if anyone still cares about this, I did manage to get no-HALT sector
writing to work on a standard shack FD501 controller. At first I had
difficulty, but after reading the description of the Write Sector command in
the 1773 datasheet, it became clear what the problem was. The FDC sets the
DRQ status bit long before it is actually ready to write your data. After
you respond to the initial DRQ by supplying the first byte, you have to wait
for the FDC to process 36 gap bytes, 1 Data Mark byte, and your first data
byte before it gives you another DRQ. This means you need an additional loop
just to wait for the second DRQ.
Below is a listing of the main portion of the write routine. I created a
modified version of Disk Basic 1.1 which uses this for sector writes in
DSKCON. I tested it by perfoming a BACKUP, and it worked without error. I
ran it on a stock CoCo 2 (0.889 mhz 6809e). The routine would probably need
to be modified in order to work at higher speeds.
LDY #0 ; PREP TIMEOUT COUNTER
LDU #$FF48 ; POINTER TO FDC REGISTERS
LDB #$02 ; THE DRQ MASK
WAIT1 BITB ,U ; READY FOR FIRST BYTE?
BNE WRFRST ; BRANCH IF READY
LEAY -1,Y ; DECREMENT TIMEOUT COUNTER
BNE WAIT1 ; KEEP WAITING FOR DRQ
JMP NOTRDY ; GO HANDLE TIMEOUT ERROR
WRFRST LDA ,X+ ; FIRST BYTE FROM BUFFER
STA 3,U ; GIVE IT TO FDC
LDA ,X+ ; SECOND BYTE FROM BUFFER
WAIT2 BITB ,U ; WAIT FOR FDC TO WRITE..
BEQ WAIT2 ; ..GAP, DATA MARK, BYTE 1
WRLOOP STA 3,U ; GIVE DATA BYTE TO FDC
LDA ,X+ ; GET NEXT DATA BYTE
BITB ,U ; CHECK FOR DRQ AND..
BNE WRLOOP ; ..BRANCH IF READY
BITB ,U ; CHECK AGAIN
BNE WRLOOP
BITB ,U ; ..AND AGAIN
BNE WRLOOP
BITB ,U ; ..AND ONE LAST TIME
BNE WRLOOP
CWAI #$FF ; DONE! WAIT FOR NMI
More information about the Coco
mailing list