Minimalist ECB (MECB) – CompactFlash Interface Card

I’ve now added a CompactFlash Interface Card to the MECB Card range, enabling any of the MECB CPU Cards to be expanded with a Mass Storage solution.

Join me, as I introduce the background and then demonstrate the CompactFlash Interface Card in operation.

I then get more technical by reviewing the schematic and PCB layout, as well as taking you through the assembly of one.

Finally, I walk-through my 6809 Assembly source code for the “CompactFlash Utility” (which I’d initially demonstrated).

Minimalist ECB (MECB) – CompactFlash Interface Card | Plus some 6809 Assembly Coding

Introduction & Background

In my previous Blog / Video, I demonstrated my new Banked Memory Expansion Card, for my 8-bit CPU Cards.

This gave us up to 3.5MB of RAM available (using multiple 1MB Cards), for supporting larger memory 8-bit applications, or, for implementing an operating system.

The next logical step was to add a Mass Storage solution. This would then enable us to boot-load a larger application, or, an operating system, which is too large for our on-board ROM.

For providing some Mass Storage for our 8-bit creations, I’ve actually been designing a couple of solutions.

The first of which, is the CompactFlash Interface Card, which I’m presenting today.

CompactFlash Interface Card Demonstration

On my workbench (below), you can see the assembled card, which I’ll shortly plug into my MECB backplane for an initial demonstration.

Fully assembled MECB CompactFlash Interface Card on my workbench!

If you’re familiar with my previous blogs / videos, you’ll know that I traditionally follow my own sequential step-by-step progress through a project.

But, I now understand that some folk are really only interested in seeing the finished product being demonstrated.

So, on this occasion, I thought I’ll try out a new sequence of first showing the completed project, before I then move on to the more technical stuff of showing how I got there (for those who are interested).

Feel free to leave a comment in the discussion Forum (or, as a Video comment), if you have a preference either way. I can then take your feedback into account for guiding the preferred format for future project Blogs / Videos.

Okay, so to demonstrate my completed CompactFlash Interface Card, first I’ll get the completed card inserted into my MECB backplane.

Note that my backplane also has my 6809 CPU Card, my Motorola I/O Card, and also my Banked Memory Expansion Card (from my last Blog / Video).

But, it’s important to note that the CompactFlash Interface Card doesn’t actually require the Banked Memory Expansion Card. I just happen to still have it installed in my backplane, from my last video.

For the first demonstration, I next insert a known good (already succesfully tested), 256MB CompactFlash Card, and then I plug our CompactFlash Card into our backplane, so we’re all ready to go!

Powering-up, we get our ASSIST09 Monitor prompt (shown below).

Initial power-up ASSIST09 prompt. In this case enhanced with our Banked Memory Expansion Card.

I’ve spent the last part of this project, coding and optimising my own CompactFlash Utility, written in 6809 Assembly Code.

This has been a fun journey, which actually took a few days longer than I’d planned. This was basically due to my ongoing tendency towards perfectionism.

This means that I’m only happy to think of something as complete (for now), when I finally wake-up in the morning, without the usual thought of yet “one more thing” which I could add to further improve the code, or the functionality.

Note that I qualified the above with “for now”, as all software developers know, that no application is ever “finished”! 🙂

So, for this demonstration, I’ll transfer my assembled code across to my 6809 CPU Card.

Later, I’ll do a code walk-through, for those who are interested in 6809 Assembly coding.

With the code transferred, I then run my assembled code with the ASSIST09 Go command. Specifically: G 0100.

Initial “CompactFlash Utility” run output, with our tested Successful CompactFlash Card installed.

Straight away, you’ll see that the “CompactFlash Utility” presents information on the inserted CompactFlash Card, and then progresses to complete a full non-destructive test of reading Sector data from, and writing Sector data to, the inserted CompactFlash Card.

This quickly enables us to see if our inserted CompactFlash Card is good, and working as expected.

Now, because CompactFlash Cards from different manufacturers can perform and support different capabilities (the CompactFlash specification lists several features as “optional”), there are a couple of things to note from this initial reporting and testing.

Firstly, we want to review that all of the tests are reported as Successful!

Secondly, we want to check that the reported “Total Sectors Addressable” actually matches the expected card capacity.

In this case, we can decimal convert the reported maximum addressable sector of 00 07 A8 00 and see that if we multiply the decimal equivalent by the 512 Sector size, we do indeed have around 256MB of capacity.

Confirming that the “Total Sectors Addressable” actually equates to the expected CompactFlash Card capacity!

To give you an example of CompactFlash Cards that have failed these tests, I’ll later insert a couple of my failed CF Cards, to demonstrate the results I get.

I’ll also go into more detail later in this Blog, to explain why not every CompactFlash Card works.

But I’ll leave that for the more technical part of this Blog.

For now let’s first have a further look at what my CompactFlash Utility does.

Now, after the initial CF Card information report, and the non-destructive Sector read and write test results, you’ll notice that we have a hash # prompt.

This is to differentiate from our usual greater-than > ASSIST09 monitor prompt.

So, if I now enter a Question Mark ? (for help), you’ll see a list of supported commands.

Display of available “CompactFlash Utility” commands, with the ? (Help) command.

As you can see, I have implemented a quite comprehensive CompactFlash support utility.

We can:

  • Display our Sector Buffer.
  • Fill our Sector Buffer with a specified byte.
  • Invert (or Complement) our Buffer content.
  • Specify the Sector Address that we want to access on our CompactFlash card.
  • Read a sector from the CompactFlash card into our buffer.
  • Write our Buffer into a CompactFlash Sector.
  • Verify if a CompactFlash Sector matches our Buffer content.
  • Read and Report on our CompactFlash card’s Identity information.

In addition we can determine if the reporting displayed is detailed or simple.

This is mostly useful for the Verify command, where we can choose to have a simple successful or failure message, or we can choose to see the detail of every Verification data byte mis-match.

Finally, we can quit back to ASSIST09 with Q

If you’d like to see each of the commands demonstrated, then this is best achieved by watching the linked Video, where I walk-through a few command demonstrations.

Incompatible CompactFlash Cards

Next, I’ll show you two examples of faulty, or (more correctly), “incompatible” CompactFlash Cards.

Firstly, let’s remove our good CompactFlash Card, and then we’ll try running the CompactFlash Utility again.

Our CompactFlash Utility just exits with a “No CompactFlash Card Detected”, if none is inserted!

As you’ll note, the absence of a CompactFlash Card is detected, and we’re just thrown back to ASSIST09, as there is nothing more to do.

So, let’s power-off and insert our first faulty card.

With an incompatible (or faulty) CompactFlash Card inserted, we then power-on, transfer our utility, and run it again.

Our first “incompatible” Card is an obvious failure. With garbage characters and a Sector Read failure!

From this you’ll see an obvious failure. We have garbage characters reported for the Compact Flash identity, and, we have a Sector Read attempt failure. Pretty obviously a faulty, or non-compatible, CompactFlash Card.

Okay, so let’s just call that a failed CompactFlash Card.

Let’s now power-off and insert our second faulty or incompatible card, and then power-on, and transfer / run our utility again.

Our 2nd “incompatible” initially looks okay. But look at the “Total Sectors Addressable”!

This time things are looking quite good. We have some apparently meaningful Card identity information, and (most importantly), we have successful messages for a Sector read, write, and verify.

Looking good?

But, this is where we notice something suspicious.

As I noted earlier, we want to also check our reported Total Sectors Addressable count, actually makes sense!

In this case, the reported Addressable Sector Count is: 08 07 A8 00

A decimal conversion of this equates to around 70GB of addressable data, which does not match the 256MB size of our inserted CompactFlash Card!

“Total Sectors Addressable” equates to about 70GB! On out 256MB CompactFlash Card this makes no sense!

Obviously this is not correct, and although the initial read and write tests have been successful, this Card is obviously not what it claims to be.

Okay, so this completes our initial demonstration of our new MECB CompactFlash Interface Card, in operation, and the use of the 6809 based “CompactFlash Utility” software, which I’ve written.

But, please be sure to also visit the section further below, covering an Important “CompactFlash Utility” Update!

MECB CompactFlash Interface Card Kitset

Below is a photo showing all of the CompactFlash Interface Card Kitset options, which I’m making available on my online store.

Online Store MECB CompactFlash Interface Card Kitset options.

As usual, you can have the PCB only, or, you can select optional packs to make up a full Kitset.

I’ll also be offering a 256MB CompactFlash Card, which I have pre-tested for correct “8-bit True IDE Mode” compatibility, and also the appropriately reported Addressable Sector count.

Just note that I’ve currently purchased about 15 different CompactFlash Cards, of which only 3 (so far), have been fully “8-bit True IDE Mode” compatible. So, this is proving a costly exercise for me. But, I do want to find consistently good / proven CompactFlash Cards, which I can help-out fellow enthusiasts by offering as an option through my online store.

Okay, so if you’re not interested in the more technical detail, thanks for staying with us up to this point.

For the rest of you, let’s now dive into the more technical section of this blog.

CompactFlash Interface Card – Schematic

First, let’s take a look at the schematic.

MECB CompactFlash Interface Card – Schematic v1.0

The schematic is relatively simple.

As a CompactFlash Card supports an 8-bit parallel interface, I just simply use a couple of 74HCT245 TTL level bi-directional buffers to isolate the CompactFlash interface from our bus.

The first 74HCT245 is used to buffer our bi-directional data bus. This also enables our data interface to utilise pull-down resistors, without impacting any other devices on our data bus.

The pull-down Resistor Bank enables us to reliably detect a Not Ready status, when no CompactFlash Card is inserted.

However, you should note that a single pull-down resistor would have sufficed, in order to ensure the active high RDY status register bit is present. But, pulling-down all of the open data bus input signals (when a CompactFlash Card is not inserted), is a much tidier, and therefore nicer, solution.

Without the pull-down, the absence of a CompactFlash Card would just present high-impedance floating signals to the data bus, delivering inconsistent logic levels when we try to read the status register on our non-existant CompactFlash Card.

CompactFlash Card Status Register bits, noting the RDY bit (active High), used to detect our CompactFlash Card.

The second 74HCT245 is used to buffer our bus originating address and control signals.

Interestingly, in the earlier days we would have chosen a 74LS244, or in more modern days a 74HCT244 uni-directional octal buffer. Specifically, for buffering the uni-directional signals, we (of course), have no need for the bi-directional capability of the 74HCT245.

However, we have now arrived at a point in time where the more complex 74HCT245 chip is actually a lot cheaper to source than a lesser complex 74HCT244 chip.

No doubt this situation is simply due to the popularity, and therefore the higher demand, of the 74HCT245.

So, for this uni-directional requirement, we simply hard-wire the direction pin, so that it behaves like a 74HCT244, and then we enjoy the savings, and further add to the popularity of the 74HCT245.

Finally, we have our usual MECB 16V8 PLD glue logic, which gives us the flexibility of our memory map allocation.

The interface uses a CompactFlash Card in the “True IDE Mode”. This mode uses 8 addresses for its interface, as can be seen from its use of the lower three address lines: A0 – A2

I’ve therefore allocated it’s default MECB address space to the 8 byte I/O address block $18 – $1F

CompactFlash Interface Card – PCB layout

So, let’s now take a look at the PCB layout.

Render of MECB CompactFlash Interface Card PCB Layout v1.0

As you can see the PCB layout is quite tidy, with my usual MECB Card layout, but with a large cut-out to accommodate a CompactFlash IDE44 Adapter module, which is mounted flush with the Card.

This ensures we don’t need any fine surface mount soldering, and its positioning also allows an inserted CompactFlash Card (itself), to naturally protrude from the MECB Card edge. This is exactly what we’d want if our MECB system was mounted in a case.

Now, I mentioned that our 8-bit interface uses the CompactFlash in “True IDE Mode”.

So, we should first talk a bit more about that.

CompactFlash “True IDE Mode”

True IDE Mode is supported by all CompactFlash Cards, but is only an optional feature of newer CompactFlash+ Cards.

Fortunately, we don’t need huge GB capacity for our 8-bit creations, therefore older (and smaller capacity), CompactFlash Cards are perfect for our requirements.

Even so, the True IDE mode still supports addressing up to 512GB of storage. This is way more than we’d ever need!

Another point we need to be aware of, is that the CompactFlash specification notes that “True IDE Mode” is only reliably selected by the tied-low state of a specific input pin, when power is first applied (refer below).

CompactFlash Specification r3.0 – Description of “True IDE Mode” function.

There are other methods for the detecting “True IDE Mode” selection, however the CompactFlash specification notes that these other methods are all optional.

This has a couple of implications.

Firstly, the use of hot-swap of a CompactFlash Card cannot be reliably supported.

Swapping a CompactFlash Card while power is applied, means that the power pins are connected, before the True IDE Mode selection pin is grounded. This means that True IDE Mode detection during hot-swap, relies on the Card supporting an optional True IDE Mode detection method.

i.e. Inserting a CompactFlash Card with power applied, will not reliably work for all CompactFlash Cards.

Secondly, we simply need to be aware that True IDE Mode (itself), is not supported by every CompactFlash Card out there.

For this reason, you can probably see why my CompactFlash Utility performs all of the tests that it does, and why I demonstrated the examples of two CompactFlash Cards failing in their tests.

CompactFlash Interface Card – Kitset Assembly

Next, I’ll walk-through my CompactFlash Interface Card assembly.

For this you’ll now see below, all of the components needed for assembly are laid-out on my workbench.

All parts laid out on my workbench, for MECB CompactFlash Interface Card assembly.

Let’s dive into assembly. For a complete walk-through of my assembly process, be sure to watch the linked Video.

But, in summary, I start-off with the lowest profile parts, which in this case are my round-pin IC Sockets.

Then we add the Resistor Network and Bypass Capacitiors. Next, the CompactFlash Adapter module.

Finally, I solder in place the DIN 41612 bus connector, which is held in place with two M2.5 10mm bolts.

With the soldering complete, I then insert the three ICs, and also attach the PCB spacers to support my Card connected to the horizontal backplane connector.

With assembly complete, now is the point where I’d normally demonstrate the completed Card.

But as you’ll recall, for this Blog / Video, I’ve tried the experiment of moving the demonstration segment to the start.

So, let’s now dive into the code walk-throughs.

If you’re not interested in the code walk-through, then I recommend jumping ahead to the “Compact Flash Utility” Update section, where I cover an important addition I’ve made to my CompactFlash Utility’s initial tests (in addition to those checks earlier demonstrated).

Right, on with the code walk-throughs.

PLD Source code walk-through

We’ll first take a look at the 16V8 PLD source code.

Below you can see the header of my PLD source code, which I manage in WinCUPL II, which is available for free from MicroChip.

Header of my PLD source code – Full source file (and compiled .jed file), is available from Github.

For my full walk-through of the PLD source, please view the linked video.

Otherwise, you can just download the .pld source from the MECB Github. There you’ll also find the compiled .jed file, which can be directly used for programming your 16V8 PLD.

“CompactFlash Utility” 6809 Assembly code walk-through

Next, let’s take a look at my 6809 Assembly coded “CompactFlash Utility” source code.

Header of my 6809 Assembly coded “CompactFlash Utility” – Full source file is available from Github.

For my full walk-through of the “CompactFlash Utility” 6809 Assembly source code, please view the linked video.

Otherwise, you can just download the .asm source from the MECB Github. There you’ll also find the assembled .s19 file for directly transferring the assembled “CompactFlash Utility” to your 6809 system.

Important: “CompactFlash Utility” Update

So, to finish up, I’ll show you the updated “CompactFlash Utility” initial checks reports.

As I mentioned during the code walk-through (on the video), I had discovered another CompactFlash “True IDE Mode” incompatibility failure issue.

This was that, when writing a sector to the CompactFlash Card (in 8-bit “True IDE Mode”), an incompatible CompactFlash would actually corrupt other sectors.

Therefore, I added an additional multi-sector test to our existing initial checks.

Below is a screen-shot of the new initial run output, for a successfully checked CompactFlash card.

Updated “CompactFlash Utility” initial checks output – Now with a Multi-Sector check.

As you can see in the above screen-shot, all operations are successful!

For comparison, below is a screen-shot of a CompactFlash Card that passes all of the initial checks, but then fails this new “Multi-Sector” check.

Updated “CompactFlash Utility” initial checks output, for a Card that has Failed the new Multi-Sector check.

The Card had past the initial single sector tests, but when a second sector was written, the initial sector was corrupted, as can be seen from the final verify failure.

Due to the various observed 8-bit True IDE Mode incompatibilities, what I intend to do is check every CompactFlash Card before it is sent out. As I noted earlier, so far I’ve had only 3 CompactFlash Cards that checked succcessfully, from my initial purchase of around 15 samples. Therefore, I have yet more samples on the way!

For my online store offered CompactFlash Card optional pack, I’ll also include a print-out of the CompactFlash Utility test result (as shown below).

Online Store supplied 256MB CompactFlash Card optional pack, with verified checks print-out.

Okay, so that completes my introduction of the MECB Compact Flash Interface Card.

As usual, you’ll find all of the published resources on the MECB Github.

Hopefully, in addition to getting you up-and-running, the “Compact Flash Utility” Assembly source code, will also provide you with the low-level subroutines that you can re-use for your own CompactFlash based applications.

So, as I usually say, Have Fun!

Discussion

Discuss this post on the Forum