home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug117.arc
/
WD2793.LBR
/
WD2793.DQC
/
WD2793.DOC
Wrap
Text File
|
1979-12-31
|
12KB
|
271 lines
WD1793/2793 Floppy Disk Controller
Thesσá note≤ wil∞ givσ brieµ detail≤ fo≥ programminτ thσ WD279│
flopp∙á disδá controller«á Therσ arσ mino≥á difference≤á fo≥á thσ
WD197│ controller¼ bu⌠ wil∞ no⌠ bσ considereΣ here¼ anΣ thu≤ thi≤
can be considered as valid for that controller too.
Notσ thesσ detail≤ havσ beeε tailoreΣ toward≤ thσ Impementatioε
iεá thσ microBeσ anΣ hencσ somσ detail≤ havσ beeε ignoreΣ a≤ the∙
arσá oµ n∩ interes⌠ iε thi≤ situation¼á anΣ somσá specific≤á onl∙
relatσá t∩á thσá MicroBeσá (sucΦ a≤ methoΣ oµá disδá anΣá densit∙
selectioε)
------$$$$$$------
Section One Register Information
Registers
---------------------------------------------------------------
A0 A1 Read Write 'Bee Addr
---------------------------------------------------------------
0 0 Status Register Command Register 44H
0 1 Track Register Track Register 45H
1 0 Sector Register Sector Register 46H
1 1 Data Register Data Register 47H
---------------------------------------------------------------
Commands (simplified)
---------------------------------------------------------------
Command Bits
7 6 5 4 3 2 1 0
---------------------------------------------------------------
Restore 0 0 0 0 h V r1 r0
Seek 0 0 0 1 h V r1 r0
Step 0 0 1 T h V r1 r0
Step-in 0 1 0 T h V r1 r0
Step-out 0 1 1 T h V r1 r0
Read Sector 1 0 0 m 1* E 0* 0
Write Sector 1 0 1 m 1* E 0* 0
Read Address 1 1 0 0 0 E 0 0
Read Track 1 1 1 0 0 E 0 0
Write Track 1 1 1 1 0 E 0 0
Force Interrupt 1 1 0 1 I3 I2 I1 I0
---------------------------------------------------------------
* use these values for compatibility with 2795/7
Flag Summary
r1 r0 Stepping Rates see chart below
╓á TracδáNumbe≥áVerif∙ ╓ ╜ 0¼án∩ verif∙
╓á╜á1, verify destination track
h Head Load Flag h = 0, unload head at beginningè h = 1, load head at beginning
T Track Update Flag T = 0, no update
T = 1, update Track Register
E Delay E = 0, no delay
E = 1, 30 msecs delay
m Multiple Record m = 0, single record (sector)
Flag m = 1, multiple records (sectors)
Ix Interrupt Conditions see chart below
--------------------------------------
r1 r0 Head Stepping Rates
--------------------------------------
0 0 6 msecs
0 1 12 msecs
1 0 20 msecs
1 1 30 msecs
---------------------------------------
------------------------------------------------------
Ix = Interrupt Condition Flags
------------------------------------------------------
I0 = 1 Interrupt on Not Ready to Ready Transition
I1 = 1 Interrupt on Ready to Not Ready Transition
I2 = 1 Interrupt on Index Pulse
I3 = 1 Interrupt Immediate (requires a reset)
I3 - I0 = 0 Terminate with NO Interrupt
------------------------------------------------------
---------------------------------------------------------------
Status Register Bit meanings
---------------------------------------------------------------
S7 after all commands 1 = not ready
0 = ready
S6 after seek/write command 1 = write protected
0 = not write protected
S5 after seek command 1 = head loaded
0 = head not loaded
S╡ afte≥ reaΣ commanΣ ▒ ╜ deleteΣ datß addres≤ mark
0 = Data Mark
S┤áafte≥áseeδácommanΣá ▒á╜áseeδáerro≥á(tracδ no⌠ verified)
0 = OK or verify not requested
S4 after read/write 1 = Record (Sector) Not found
sector command 0 = OKè
S3 after seek, read/write 1 = CRC error
secor command 0 = OK
S2 after seek command 1 = Track Zero
0 = Not Track Zero
S2 after read/write 1 = Lost Data
command 0 = OK
S1 after after seek command 1 = Index Pulse
0 = no Index Pulse detected
S1 after read/write command 1 = Data Transfer Request Active
0 = no Data Transfer Request Active
S0 all commands 1 = Busy (command in progress)
░á╜ No⌠áBus∙
---------------------------------------------------------------
-----------------------------------------------------------
Select/Side/Density Latch (MicroBee Only) Write Addr 48H
-----------------------------------------------------------
bit 0 LSB Drive Address
bit 1 MSB Drive Address
bit 2 Side Select (0 = side 0, 1 = side 1)
bit 3 Density Select (0 = SD, 1 = DD)
------------------------------------------------------------
Drive Addresses 00 = A, 01 = B, 10 = C, 11 = D
------------------------------------------------------------
Transfer Status Bit (MicroBee Only) Read Addr 48H
------------------------------------------------------------
bit 7 bit = 1 Data or Interrupt Request Active
bit = 0 No Data or Interrupt Request
------------------------------------------------------------
------$$$$$$------
Section Two Code Examples
;code to restore head of currently selected disk to track zero
ld a,00bh ; restore, load head, slow step rate
cmd_out:out (044h),a ; send to command register
call delay ; call mandatory delay
ready: in a,(044h) ; read status registerè bit 0,a ; still busy ?
jr nz,ready ; yes, go back and try again
ret ; complete
╗á dela∙ mus⌠ allo≈ time betweeε commanΣ writσ anΣ statu≤
; read
delay: ld a,010h ; number of loops
loop: dec a ; decrement count
jr nz,loop ; finished ?
ret
; code to seek to a given track/sector
; ( assume track in D register, sector in E register)
ld a,d ; load a with track
out (047h),a ; load track into floppy data reg
╗ yes¼ thi≤ i≤ correct. Thσ tracδ
; register contains current track
╗áposition«áI⌠ái≤áuseΣáb∙ control
; ler to calculate direction and
; number of steps needed.....
ld a,01dh ; seek command, 12 msecs steps
call cmd_out ;
ld b,00ah ; delay value
call big_delay ; wait awhile
in a,(044h) ; read floppy status register
and 018h ; look at seek and crc bits only
push af ; save
ld a,e ; get sector address
out (046h),a ; write to floppy sector register
pop af ; go and examine status
; (not shown)
big_delay:
push hl ; save register
delay1: ld hl,0007ah ; inner loop value
delay2: dec hl
ld a,h ; bug in 8080/Z80 dec hl
or l ; does not set flags
jr nz,delay2 ; finished inner loop ?
djnz delay1 ; finished outer loop ?
pop hl ; restore
ret ; complete
╗ácodσát∩áreaΣá51▓ bytσ secto≥á (assume≤ádrive/track/sector»
; selected⌐
ld b,000h ; count of 256 times 2 bytes
ld c,048h ; data transfer request port
lΣ hl,data_addres≤ ╗álocation iε memor∙ for data
dΘá ╗ canno⌠áafforΣáinterrupt≤
ld a,088h ; read sector command
call cmd_out ; as above
loop1: in a,(c) ; get transfer port status
jp p,loop1 ; bit 7 = 1 ?, no try againè in a,(047h) ; yes, read the data register
ld (hl),a ; store byte in memory
inc hl ; increment address
loop2: in a,(c) ; get transfer port status
jp p,loop1 ; bit 7 = 1 ?, no try again
in a,(047h) ; yes, read the data register
ld (hl),a ; store byte in memory
inc hl ; increment address
djnz loop1 ; loop till all 512 bytes read
ei ; time critical part is over now
call ready ; get floppy status
╗á wσ woulΣ theε examinσ thσ stau≤ fo≥ success¼á iµ no⌠ retr∙ thσ
; operation until the retry count (typically 16x) is exhausted
; (code not shown for this)
------$$$$$$------
Section Three Formatting
T∩á forma⌠á ßá tracδá ß ful∞ tracδá writσá operatioεá i≤á giveε
followed by data bytes in a given sequence. Certain rules must be
addherred to, a typical sequence for double density is :-
80 bytes of 4e hex for clock sync and gap
AAA 12 bytes of 00 hex clock sync
3 bytes of f5 hex writes special a1 on floppy
1 byte of fe hex ID address mark
1 byte of xx hex track number goes here
1 byte of xx hex 00 or 01, the side number (MicroBee
always uses 0 for both sides!)
1 byte of xx hex sector number goes here
1 byte of xx hex sector length 00=128 01=256 02=512
03=1024
1 byte of f7 hex write CRC character
22 bytes of 4e hex for clock sync and gap
12 bytes of 00 hex clock sync
3 bytes of f5 hex writes special a1 on floppy
1 byte of fb hex data address mark
xx bytes of e5 hex data - 128, 256, 512 or 1024 bytes long
1 byte of f7 hex write CRC character
50 bytes of 4e hex for clock sync and gap
loop to AA┴ unti∞ al∞ sector≤ donσ then paΣ res⌠ oµ tracδ witΦ 4e's
Thσá numbe≥á oµ byte≤ oµ 4E anΣ 0░ varie≤ dependinτ oε ho≈á man∙
sector≤á onσ i≤ tryinτ t∩ squasΦ ont∩ ß track.....MicroBeσ value≤
arσálower. See disassemblyáof DDFORMAT fo≥ aε eas∙á t∩áunderstanΣ
format program. You will see some of the examples above used.....
Tony Ellis VK2ZNH
13.09.87