Atari ST MFP

Description

The Atari ST uses the MC68901 Multi-Function Peripheral chip (MFP) from the MC68000 family to combine the functions of a serial interface, a parallel interface, a timer and an interrupt generator.

For TOS Timer B controls HBLANK on the display, Timer C is the 200Hz clock that drives the system timers, and Timer D belongs to the RS232 serial line. You could use the timers in a similar way to the Intel 8255 Counter Timer Chip on a PC. With the ST we can use these timers for our own purposes if we are programming a game or a demo that requires regular timing.

Example usage

It is very common for demos to use Timer A for music and high frequency sample replay and Timer B for rasters. It is less common to use Timer C for music replay because it is somewhat unpredictable to say when it will be triggered so it may make rasters on Timer B flickery. It is more common to call the music replay routine in the VBL interrupt or main loop of a demo while the raster is in the first few scanlines leaving the rest of the processor time for accurate raster display and border removal techniques etc.

Tight demo code does not need to use the VBL interrupt to trigger things at the start of the VBL. It can sit in a tight loop and then wait for the vertical blank to occur. This is simple code. Timer B code is necessary however for border removal.

The order in which effects in demos have to be done is important. If it takes 7% CPU time to play a Mad Max (TFMX) tune then we cannot wait the 12000 or so clock cycles to open the top border, so it would be a better idea to play the music after that is done. We may also have to use Timer B to wait until scanline 200 to open the lower border.

In the Atari ST Internals book there is a register block diagram but it doesn't show the base address of where the registers are so it's a bit hard to follow. This is a screenshot from the STEEM Atari ST Emulator Debugger.

Register Details

I have listed the bits for every register by name here:

Address Name Bitfield
128 64 32 16 8 4 2 1
$FFFFFA00 MFP GPIP (1) mono rs232ringind FDC/HDC ACIA Blitter rs232 CTS rs232 data carrier centronics busy
$FFFFFA02 MFP AER (2) mono rs232ringind FDC/HDC ACIA Blitter rs232 CTS rs232 data carrier centronics busy
$FFFFFA04 MFP DDR (3) mono rs232ringind FDC/HDC ACIA Blitter rs232 CTS rs232 data carrier centronics busy
$FFFFFA06 MFP IERA (4) mono rs232 ring TIMER A RX buf full RX error TX buf empty TX error TIMER B
$FFFFFA08 MFP IERB (5) FDC ACIA TIMER C TIMER D Blitter CTS rs232con LPT
$FFFFFA0A MFP IPRA (6) mono rs232 ring TIMER A RX buf full RX error TX buf empty TX error TIMER B
$FFFFFA0C MFP IPRB (7) FDC ACIA TIMER C TIMER D Blitter CTS rs232con LPT
$FFFFFA0E MFP ISRA (8) mono rs232 ring TIMER A RX buf full RX error TX buf empty TX error TIMER B
$FFFFFA10 MFP ISRB (9) FDC ACIA TIMER C TIMER D Blitter CTS rs232con LPT
$FFFFFA12 MFP IMRA (10) mono rs232ring TIMER A RX buf full RX error TX buf empty TX error TIMER B
$FFFFFA14 MFP IMRB (11) FDC ACIA TIMER C TIMER D Blitter CTS rs232con LPT
$FFFFFA16 MFP VR (12) V7 V6 V5 V4 S . . .
$FFFFFA18 MFP TACR (13) . . . low extern subdiv2 subdiv1 subdiv0
$FFFFFA1A MFP TBCR (14) . . . low extern subdiv2 subdiv1 subdiv0
$FFFFFA1C MFP TCDCR (15) . Csubdiv2 Csubdiv1 Csubdiv0 . Dsubdiv2 Dsubdiv1 Dsubdiv0
$FFFFFA1E MFP TADR (16) 0 0 0 0 0 0 0 1
$FFFFFA20 MFP TBDR (17) 0 1 0 1 0 0 0 0
$FFFFFA22 MFP TCDR (18) 0 0 1 0 1 0 1 0
$FFFFFA24 MFP TDDR (19) 0 0 0 0 0 0 0 1
$FFFFFA26 MFP SCR (20) 0 0 0 0 0 0 0 0
$FFFFFA28 MFP UCR (21) freq/16 wordlen1 wordlen0 startstopbits&sync1 ss&s0 parity on parity even .
$FFFFFA2A MFP RSR (22) full overrun parity err frame err break match sync strip enable
$FFFFFA2C MFP TSR (23) empty underrun auto turnaround end break H L enable
$FFFFFA2E MFP UDR (24) 0 0 0 0 0 0 0 0

Notes

  1. The high byte of each word is 255 (0xFF).
  2. The control bits are in the low byte so we read/write $FFFFFA01, $FFFFFA02 etc.
  3. To enable Timer C after its frequency has been set for example we have to call ORI.B #32,$FFFFFA09.W
  4. It is very common to save all the values of the registers in a stack to restore them when the program ends to allow the caller to resume as normal.

Interrupt Priorities

Priority        Description
15 (HIGHEST)    Monochrome monitor detect
14              RS232 ring indicator
13              System clock (timer A)
12              RS232 receive buffer full
11              RS232 receive error
10              RS232 transmit buffer empty
9               RS232 transmit buffer full
8               Horizontal blanking counter (MFP timer B)
7               Disk drive controller
6               Keyboard and MIDI (ACIA)
5               MFP timer C
4               RS232 baud rate generator (MFP timer D)
3               GPU operation done
2               RS232 Clear To Send (CTS)
1               RS232 Data Carrier Detect (DCD)
0 (LOWEST)      Centronics busy

Links

Timing on the Atari ST
A programmers reference to the Atari ST

Back to index.