# The MFP (MK68901 / MC68901) ## The chip (DOC: MK68901, Mostek 1982-12, the part HWSPEC names; MC68901, Motorola 1984-01) Eight general-purpose I/O lines (GPIP) with an active-edge register and a data-direction register; sixteen interrupt channels in two banks (A and B) with enable, pending, in-service and mask registers, fixed priority, and a vector register whose top four bits are the vector base and whose S bit selects software end-of-interrupt (the in-service bit stays set until the program clears it) or automatic; four 8-bit timers (A and B with delay, event-count and pulse-width modes; C and D delay only), each with a prescaler of 4, 10, 16, 50, 64, 100 or 200 (MK68901 "Timer Control Registers"); a USART with its own control, status and data registers, clocked from Timer D's output on the ST. 24 registers on odd bytes at FFFA01-FFFA2F (HWSPEC 9). ## How the ST wires it (DOC: HWSPEC 10, 5.2; SVC "MFP Interrupt Control", "RS232C Interface") | Priority | Channel | Source on the ST | | --- | --- | --- | | 15 | GPIP 7 | monochrome monitor detect (STE: XOR DMA sound active: STEADD) | | 14 | GPIP 6 | RS-232 ring indicator | | 13 | Timer A | "System Clock / BUSY" in HWSPEC; its event input is the STE's DMA-sound-active signal (STEADD); free for programs on the ST (see C below) | | 12-9 | USART | receive buffer full, receive error, transmit buffer empty, transmit error | | 8 | Timer B | horizontal blanking counter: its event input is DE (HWSPEC 5.2) | | 7 | GPIP 5 | disk controller (FDC and HDC interrupt, FDINT/HDINT: SVC) | | 6 | GPIP 4 | keyboard and MIDI ACIAs (wired-OR; the ACIAs' IRQ bits tell which: HWSPEC 10 note) | | 5 | Timer C | (TOS's 200 Hz system tick, below) | | 4 | Timer D | RS-232 baud rate generator | | 3 | GPIP 3 | "GPU Operation Done": the Blitter's done line on the Mega ST/STE (BLIT) | | 2 | GPIP 2 | RS-232 CTS | | 1 | GPIP 1 | RS-232 DCD | | 0 | GPIP 0 | Centronics BUSY | - The MFP's interrupt reaches the 68000 at **level 6** through GLUE (HWSPEC 10); the MFP answers the acknowledge with its own vector (DIACK), not an autovector (SVC). - **Clocks**: the timers run from a **2.4576 MHz** clock "to the MFP" (DOC: SVC "RS232C Interface"; the TT's MFPs have the same, TTHRM); the bus side runs at the system's 4 MHz (MAME's MFP device is 4.01 MHz: OBSERVED). Two unrelated crystals: the timers are their own clock domain inside the board ([domains-and-speed.md](domains-and-speed.md)). - **What TOS 1.04 does with it** (OBSERVED, MAME 0.285 trace, 60 frames from reset, [mame-oracle.md](mame-oracle.md)): vector register 48h (vectors from 100h, software end-of-interrupt), Timer C/D control 51h and Timer C data C0h (2,457,600 / 64 / 192 = **200 Hz**, the system tick), Timer D data 2 with prescale 4 (the baud clock), the USART control 98h; 87 writes of 0 to ISRB in one second (the tick handler's end-of-interrupt). **C (conflict)**: HWSPEC (1986) names Timer A "System Clock"; TOS 1.04 uses Timer C at 200 Hz for its tick (OBSERVED above). HWSPEC describes an early plan; the board follows the wiring (Timer A's input pin is TAI, BUSY per HWSPEC's label), not the label. ## Corners the board must model (each needs evidence: U9-U11) - The delay between an input edge (Timer B's DE, the GPIP lines) and the pending bit, and between a timer's time-out and its interrupt: Clock Signal's ST carries a fixed "MFP recognition delay" folded into its DE timing with its author's "HACK HERE ... MUST FIX" (OBSERVED, `Video.cpp`). The MFP data sheets give the input synchronisation in clock periods (to be read and cited at milestone 3). - Reading a timer's data register while it counts (the value seen between prescaler ticks). - Writing a timer's data register while it runs (takes effect at the next reload, per the data sheets; check). - The interaction of the in-service bits with priority (software end-of-interrupt mode: a lower channel cannot interrupt while a higher one is in service). - The interrupt acknowledge's cycle cost (a vectored acknowledge through DTACK). ## Chip rule The MC68901 is also the Sharp X68000's MFP (its Phase 0 runs tonight in `../x68000-python`; MAME's `sharp/x68k.cpp` uses it, OBSERVED through ym2151-python's users table). By the chip rule a non-CPU chip used by a second family board gets its own core: **propose `mc68901-python`**, extracted when the second of the two boards starts building, with each machine's wiring outside the core (the GPIP map, the clocks, the vector base are board facts). Until then it lives in the first board behind a pin-shaped class (`Mfp68901`), as the charter says. The x68000-python Phase 0 (`c092694`, its docs/cpu-cores.md and decision 5) proposes the same from its side: "extract if an Atari ST board starts". Open decision 4.