Porting to Other Processors

The SD card interface is not tied to any specific processor, and can be adapted to work with almost any system.  The Arduino side should remain completely “stock” in that no changes should be needed for other processors.  This section has information about how to move the low-level code to another processor.

This is not a trivial exercise, but I’ve got lots of information, code and experience to help you.  If I find most people are in the same starting point, maybe I can come up with something to make this easier, but here are the steps generally needed to get started.

Functions Needed to Access the SD Card

There are six low-level functions you’ll need to provide, but you’ll want a few more to make the disk drivers easier to write.  For our cards, I’ve put all of these into the EPROM at fixed locations so other code can just call these functions.

The PARIO file is the real driver, and is the only file that knows anything about the hardware address of the parallel port.  The five main functions of this file are:

  • Initialize the parallel port
  • Set the port to write to the Arduino
  • Set the port to read from the Arduino
  • Write a byte to the Arduino
  • Read a byte from the Arduino

All other functions call those five (usually just the last four) to perform higher level functions.  The file diskfunc.asm has a lot of sample code for higher level functions, but the three that are really required are:

  • Read a sector (needed to boot0
  • Write a sector
  • Get status of a drive

I strongly suggest putting a jump table to each of these functions at a known location in your monitor EPROM so they can be debugged once and then all other software calls them rather than twiddling with hardware directly.

Ready To Go Code

These are real code examples used by our boards or for ports we’ve done to other processors.  They all assume two parallel ports, one being 8 bits wide for data transfer and three bits in another port for control lines.  Pick a processor closest to the one you’re porting to, download the code, and start writing equivalent functions.

 

For the 6800:

 

For the 6809:

 

For the 6502 (not complete):