Changes between Initial Version and Version 1 of CPC-CompactFlash


Ignore:
Timestamp:
May 19, 2014, 10:22:03 PM (10 years ago)
Author:
pulkomandy
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CPC-CompactFlash

    v1 v1  
     1= CPC-CompactFlash =
     2
     3This very simple interface (only 2 74LSxx chips) allows the use of a CompactFlash memory card on the CPC. It uses the 8 bit mode of the compact flash, making it even simpler than the IDE interfaces you can find elsewhere.
     4
     5== Schematics ==
     6
     7http://www.circuitbee.com/circuit/view/0000000374
     8
     9Also available (with PCB routing) in the SVN repository.
     10
     11== Programming information ==
     12
     13The interface maps the registers at addresses FEF0-FEFF :
     14
     15|Address|Read|Wrire|
     16|FEF0|Data|Data|
     17|FEF1|Error|Feature|
     18|FEF2|Sector count|Sector count|
     19|FEF3|LBA 0|LBA 0|
     20|FEF4|LBA 1|LBA 1|
     21|FEF5|LBA 2|LBA 2|
     22|FEF6|Drive/LBA 3|Drive/LBA 3|
     23|FEF7|Status|Command|
     24
     25Sector are accessed using 28-bit sector numbers in registers FEF3-FEF6. Only the 4 low bits of FEF6 are used, the 4 high bits must be set to E to enable LBA mode on the master drive.
     26
     27=== Initializing ===
     28
     29First of all, set the compact flash card to 8-bit mode:
     30
     31{{{
     32        OUT &FEF6,&E0 ' Select master drive in LBA mode
     33        OUT &FEF2,1 ' Sector count = 1
     34        OUT &FEF3,0 ' Select first sector on drive
     35        OUT &FEF4,0
     36        OUT &FEF5,0
     37
     38        OUT &FEF1,1 ' 8bit mode feature code
     39        OUT &FEF7,&EF ' execute SET FEATURE command
     40}}}
     41
     42You can then identify the card:
     43
     44{{{
     45        OUT &FEF6,&E0 ' Select master drive in LBA mode
     46        OUT &FEF2,1 ' Sector count = 1
     47        OUT &FEF3,0 ' Select first sector on drive
     48        OUT &FEF4,0
     49        OUT &FEF5,0
     50
     51        OUT &FEF7,&EC ' Send IDENTIFY command
     52
     53        ' Wait for the card to become ready to send data
     54loop    A = IN &FEF7
     55        IF A > &7F GOTO loop
     56
     57        ' Get the drive identification in IDENT array
     58        FOR i = 0 to 512
     59                IDENT(i) = IN &FEF0
     60        NEXT i
     61}}}
     62
     63The identification data is 512 bytes long and has information about the card (manufacturer id, model number, ...) and its capacity and format, and a few other less important things.
     64
     65You can also read sectors:
     66
     67{{{
     68        OUT &FEF6,&E0 ' Select master drive in LBA mode
     69        OUT &FEF2,1 ' Sector count = 1
     70        OUT &FEF3,0 ' Select first sector on drive
     71        OUT &FEF4,0
     72        OUT &FEF5,0
     73
     74        OUT &FEF7,&20 ' Send READ SECTOR WITH RETRY command
     75
     76loop    A = IN &FEF7
     77        IF A > &7F GOTO loop
     78
     79        ' Get the sector in DATA array
     80        FOR i = 0 to 512
     81                DATA(i) = IN &FEF0
     82        NEXT i
     83}}}
     84
     85== Using a filesystem ==
     86
     87Currently, no filesystem is available. Write one or wait for AmélieDOS to be released! Meanwhile, you can have fun with reading and writing sectors.