Catweasel ISA registers

From IndividualComputers
Jump to: navigation, search

Register-level programming documentation for the Catweasel ISA. This documentation applies to both production runs, one made in 1996, and the other made in 2000, labeled "revision 2b". Although the cards look totally different, they are fully software-compatible.

Contents

Register map sorted by numbers

The Catweasel ISA is an 8-bit card, so all registers are byte-wide. It does not use any DMA or Interrupt. Three jumpers select one of eight base addresses in the computer's IO space. Register numbers are added to the base address that's set by the jumpers. The factory setting is "all jumpers closed", which puts the controller to address 0x320.

Register map sorted by numbers
0 read/write from/to S-Ram. After every access, the address counter will be advanced by 1.
1 read/write: resets S-Ram address counter, index counter and internal state machines. Prior to reading this register, you should de-select all drives and turn off all motors, so the index counter is not accidentally advanced. Reading and writing has the same effect.
2 reading returns the contents of the status register. Writing writes to the control register. Note that the control register is NOT readable, so you should keep a shadow-register in your code.
3 reading this register returns hardware version information in bit#7. See further down for a more detailed description.

Writing to this register has several functions, depending on the position of the S-Ram address counter.

If the counter is at position 0, writing to register 3 selects the clock for the pulse counters: 0=28MHz and 128=14MHz.

If the counter is at position 1, writing to register 3 sets/resets the write-enable bit: 0=disable write, 128=enable write.

If the counter is at position 2, writing to register 3 selects the index signal to be stored or not during read operation: 0=don't store index signal, 128=store index signal in MSB of every RAM-value.

4 unused.
5 writing to this register after the write-enable procedure (see further down) will start writing immediately, without waiting for anything.

Reading from this register will put the Catweasel into "wait for index" state, and then read a track starting at the beginning of the first index, ending at the end of the second index that it finds (giving you a small overlap).

6 unused.
7 Writing to this register puts the Catweasel into "wait for index" state and then writes a track starting at the beginning of the first index, ending at the beginning of the next index, causing no overlap in written data.

Reading from this register will start reading a track from floppy without waiting for anything.

Action sequences

Most of the things you want to do with the Catweasel require more than one register access, and the memory access pointer being set to a specific position. This chapter describes these actions in register access sequences.

accessing memory, setting the RAM address pointer

Reading and writing the Catweasel memory is done through a bottleneck at register 0. After every access (both read and write), the memory address pointer is advanced by 1.

The position of the RAM address pointer cannot be read from the hardware. To set the memory address pointer to a specific position, you must reset the pointer to 0 by reading register 1 and then reading register 0 N times to set the ram address counter to N. The Catweasel has 128KByte S-Ram, so the RAM address pointer is 17 bits wide.

status register read

to read the status register, read from register #2. The bit layout of this register is this:

status register
0 0=reading

1=read state machine idle

1 0=writing

1=write state machine idle

2 HDin (value of pin 2 of the shugart interface)
3 0=disk in selected drive is write protected

1=no drive selected, or disk in selected drive is write-enabled

4 0=selected drive is at track number 0

1=no drive selected or selected drive is at track position other than 0

5 0=selected drive has no disk inserted

1=no drive selected or selected drive has a disk inserted.

6 0=selected drive has motor on, and an index signal is passing by "now" (realtime bit)

1=no drive selected or selected drive does not pull index signal "now".

7 unused.

control register write

To write the control register, write to register #2. The bit layout of this register is this:

control register
0 Step bit
1 Direction bit
2 Side bit
3 Motor 1 bit: 0=on, 1=off
4 Sel0 bit: 0=selected, 1=de-selected
5 Sel1 bit: 0=selected, 1=de-selected
6 HDcontrol bit: if in doubt, please set to 1.

0 will pull pin#2 low, which is required by some older 5,25" HD drives.

1 will release pin#2, making it an input readable in bit#2 of the status regsiter

7 Motor 0 bit: 0=on, 1=off

abort any action

reading or writing register #1 will abort any current action. This may be required if you've put the Catweasel into "wait for index" state, which cannot be detected in the status register. Worst-case is that you've put the controller into this waiting state and you missed the actual "reading" or "writing" state, because all bits in the status register are real-time. This "abort" may also be required if there is no drive selected, or no disk is inserted, or the motor of the selected drive has not been switched on. Note that the hardware does NOT check this state. It is the task of the software author to make sure that the hardware does not get into an endless waiting state.

You may also need this action if you software-time your read action. Example: An Amiga disk has 11 sectors and spins at 300 RPM, which means that one full revolution of the disk takes 200ms. Since you cannot know where a sector starts, you need to read with a little overlap, which must be at least one sector. The software-timed read must therefore be at least 200ms /11*12=218.2ms.

start normal reading

To start normal reading, reset the memory pointer by writing to register #1, select a drive, turn on it's motor, step to the desired track and then read from register #7 to start the actual read action. The controller will then fill it's memory with read values until either the memory pointer overflows, or you abort reading by an access to register #1. The controller will then be in idle state, and you might want to write a short "magic" into memory to mark the end of a track: This can tell your decoder routine to "stop here", and not try to decode from un-initialized memory that may even contain data from a previous read.

start reading from index to index

To start reading from index to index, reset the memory pointer by writing to register #1, select a drive, turn on it's motor, step to the desired track and then read from register #5 to put the Catweasel into "wait for index" state. Monitor the status register and time-out your action after no less than two revolutions of the disk, which is 400ms. You can of course end your action sooner if you have seen the "reading" status bit going from "reading" to "idle". However, if you haven's seen "reading" after more than 200ms, chances are that there's no disk inserted, or the drive is not spinning.

set base-clock to 14MHz

Reset the memory pointer by reading register #1. Write value 0 to register #3.

set base-clock to 28MHz

Reset the memory pointer by reading register #1. Write value 128 to register #3.

allow index storing

Reset the memory pointer by reading register #1. Read register #0 twice to advance memory pointer to 2. Write value 128 to register #3.

forbid index storing

Reset the memory pointer by reading register #1. Read register #0 twice to advance memory pointer to 2. Write value 0 to register #3.

write-enable procedure

  • read register #1 (memory pointer is now at 0)
  • (optional): write to register #3 to choose clock speed
  • read register #0 to advance memory pointer to 1
  • write value 128 to register #3 to set write-enable bit
  • read register #0 six times to advance memory pointer to 7
  • initiate write action (immediate or index-timed)

immediate write

To start normal writing, select a drive, turn on it's motor, step to the desired track. Check that there's actually a disk inserted (bit#5 of the status register) and that it's not write-protected (bit#3 of the status register). Assuming you've already loaded track data into memory starting at memory position 7, you can now go through the write-enable procedure and then write to register #5 to start writing immediately. The controller will now write all values starting at memory position #7 until one of three events is encountered:

  • the memory pointer overflows
  • the user aborts by reading or writing register #1
  • a memory value with the MSB set has been found

The only useful termination of this action is of course to terminate your write-data with a value that has the MSB set. For compatibility of your encoders, please use 0xff as termination value, because later Catweasel models use the MSB as command-identifier.

write index to index

To start writing from index to index, select a drive, turn on it's motor, step to the desired track. Check that there's actually a disk inserted (bit#5 of the status register) and that it's not write-protected (bit#3 of the status register). Assuming you've already loaded track data into memory starting at memory position 7, you can now go through the write-enable procedure and then write to register #7 to put the controller into wait-for-index state. The controller will wait for the start of an index signal and then write all values to disk starting at memory position #7 until one of three events is encountered:

  • the memory pointer overflows
  • the user aborts by reading or writing register #1
  • a memory value with the MSB set has been found
  • a second index signal is found

read hardware version

  • Reset the memory pointer by reading register #1.
  • Advance the memory pointer to 12 by reading register #0 twelve times.
  • Read register #3 and store it's MSB as major version bit#1
  • Advance the memory pointer to 13 by reading register #0
  • Read register #3 and store it's MSB as major version bit#0
  • Advance the memory pointer to 14 by reading register #0
  • Read register #3 and store it's MSB as minor version bit#2
  • Advance the memory pointer to 15 by reading register #0
  • Read register #3 and store it's MSB as minor version bit#1

There are only two hardware versions out there, and your software should tell the user to update his MACH chip if you don't find version number 1.2 (bit combination %01.01).

Personal tools
Namespaces

Variants
Actions
Navigation
Icomp
Print/export
Administration