Files
courier-emu/docs/second-serial-port.md
T
Cryan209andClaude Opus 5 7009411316 The DSP-CPU link is the I/O-port mailbox; retract the serial-bus claim
The question was how the two processors are actually connected. The answer was
already proven and was being obscured by an argument that does not hold.

Proven, and a real round trip on the board: the ASIC bridges 80186 I/O ports to
the C5x's sixteen memory-mapped I/O ports PA0-PA15 (DSP data 0x50-0x5f). A
kernel on the DSP did `out` to 0x5e/0x5f and the 80186 read those words back at
0x58/0x5a/0x5c/0x5e.

The board inspection reporting no parallel traces was never in conflict with
that. SPRU056D Table A-8 gives DS, PS and IS as three space-select strobes on
one address/data bus, so an I/O cycle drives the same pins as a data cycle and
the ASIC sits on the SRAMs' own traces, qualified by IS. There are no separate
traces to find, which is also why the link reads as serial by eye.

Retracts "the ASIC masters the primary serial bus". That needed the codec to be
a slave, read off "register 6 = 0x20". Register 6 is the digital configuration
register and carries no master/slave bit - the role is the M/S pin (Table 2-1),
unmeasured here. Free-run is DS05 and only picks whether the rate follows A and
B or the external frame sync: meaningful in codec mode, redundant in stand-alone
mode, consistent with both. And clock mastery is a timing role, so "bus master"
would not imply "inserts its own words into DRR" even if the premise held. So
the ring at 0x0bd0 is a codec sample ring, and the inbound command path is the
mailbox, which is proven and already modelled.

With the AC01 datasheet now in docs/, the six reset control words decode: A=10,
B=20, phase 0, gain 9, analog 5, digital 0x20. That checks against the part's
own rate equation - A=10/B=20 gives exactly 7200 Hz, and B=19/18 give exactly
the 7578.95 and 8000 Hz the V.34 path selects - which fixes MCLK at 2.880 MHz,
the board's 40.320 MHz oscillator over exactly 14. Registers 7 and 8 are never
written, ruling out master-with-slaves.

Also records a lead on the live blocker that was tried and reverted: PMST.NDX
should make `lar ar0` write ARCR, which is the only mechanism found that would
leave a ring address there. It produces exactly ARCR = 0x0bdc and breaks the
firmware, because INDX takes the same value and wrecks 317 indexed-addressing
sites. SPRU056D contradicts itself on the bit's polarity, so a hardware probe is
the decider.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 14:00:55 +12:00

8.5 KiB

The DSP's two serial ports, and which end the ASIC is on

Retracted (2026-09-07). The section below titled "The ASIC masters the primary serial bus" does not hold, and the consequence drawn from it - that the ASIC inserts command words into DRR, making the ring at 0x0bd0 an inbound command stream - has no support. The argument needs the codec to be a slave on that bus, and reads that off "register 6 = 0x20". But register 6 carries no master/slave bit: it is the digital configuration register, and the role is set by the M/S pin (datasheet Table 2-1), which no measurement here has taken. Free-run (DS05) only chooses whether the conversion rate follows A and B or the external frame-sync interval; it is meaningful in codec mode, redundant in stand-alone mode, and consistent with both. Separately, being the clock and frame master is a timing role - it would not put the master's data on DIN/DOUT - so the step from "bus master" to "inserts its own words" does not follow either way. The textbook topology, the AC01 as stand-alone master driving a slave DSP, fits every firmware fact on record and is what ac01-codec-protocol.md already says. See dsp-cpu-interconnect.md.

What still stands here: the SPC/TSPC decodes, the DSP mastering the second port, and its transmitting on it continuously.

Prompted by looking at the board: the link between the ASIC and the DSP looks like a serial interface. The firmware agrees, and the two serial ports are configured for opposite roles.

The ASIC masters the primary serial bus

The two register decodes below are each unremarkable on their own. Together they force a conclusion:

  • The DSP is a slave on the primary port. SPC = 0x40c8 has MCM = 0, so CLKX is an input, and TXM = 0, so FSX is an input. The DSP neither clocks nor frames that bus.
  • The codec is a slave on it too. Register 6 = 0x20 puts the AC01 in free-run, and it is wired in slave/codec mode, where - datasheet section 2.13 - "the shift clock and the frame sync are both externally generated".

Two slaves on one synchronous serial bus need a master, and the only other device on it is the ASIC. So the ASIC generates SCLK and FS for the DSP-codec link and decides when every word moves.

That makes the ASIC exactly the parallel-to-serial bridge its 80186 side looks like: the supervisor writes it through a parallel window at ports 0x40-0x5e, and it clocks words into the DSP over a serial bus it owns.

The consequence the harness has not modelled

The codec ISR stores every word that arrives at DRR into the ring at 0x0bd0, unconditionally:

8190  mar *, ar7 ; sar ar7, @11 ; lar ar7, @10   ; the ring write pointer
8193  lamm @20                                   ; DRR - whatever was clocked in
8194  sacl *+                                    ; into the ring

and the resident's main loop walks that same ring with AR7. So the ring is not a codec-sample buffer that happens to be read - it is the DSP's inbound serial stream, and the main loop is its consumer.

The harness only ever puts line audio on that bus. If the ASIC, as bus master, also inserts its own words - which is what a parallel-to-serial bridge exists to do - then the inbound command path runs through DRR and the harness has never supplied a single word of it.

That is a different candidate for why the DSP never leaves its idle task than the ARCR gate, and it is not exclusive with it.

What the firmware programs

Both control registers are written at reset through MMR addressing, so these two sites are unambiguous:

8089  lacl #38 ; samm @32     ; TSPC = 0038  (reset held, modes set)
808b  lacl #f8 ; samm @32     ; TSPC = 00f8  (released)
...
8091  splk *, #0008           ; SPC  = 0008
8093  splk *, #40c8           ; SPC  = 40c8

Decoded against SPRU056D Table 9-13 (bit 4 MCM selects the CLKX source, bit 5 TXM the FSX direction, bit 0 is TDM on TSPC only):

register value bits MCM TXM the DSP is
SPC (primary) 0x40c8 FSM XRST RRST Soft 0, CLKX input 0, FSX input slave
TSPC (second) 0x00f8 FSM MCM TXM XRST RRST 1, CLKX output 1, FSX output master

TSPC bit 0 is clear, so the port is not in TDM multiprocessing mode - it is running as an ordinary second serial port. "TDM port" is only the register block's name here.

The two roles are exactly right for what is on each:

  • the AC01 is on the primary port and supplies SCLK and FS, which is why the DSP is the slave there - see ac01-codec-protocol.md;
  • on the second port the DSP drives both clock and frame sync, so whatever is on the other end is clocked by the DSP.

The DSP transmits on it continuously

The idle task writes TDXR every pass. 0x81b7 is the handler the idle state reaches - @1b holds 0x8138, which is intr 17, vectoring through ROM 0x0022 to @69 = 0x81b7 - and it begins ldp #000, so its sacl @31 at 0x81c9 is genuinely TDXR:

81b7  ldp  #000
81b9  lar  ar5, @74
81ba  lacc16 *+ ; adds *-      ; a 32-bit value from a pair
81bc  lt   @76 ; sath ; satl   ; scaled by TREG
81bf  sacl @7c
81c0  lar  ar5, @75            ; ...and a second one the same way
81c6  and  #00ff
81c8  add  @7c, 8
81c9  sacl @31                 ; TDXR = (first << 8) | (second & 0xff)
81ca  rete

so it packs two scaled bytes into each word. Measured at 21,976 TDXR writes in one 60,000-instruction sample window, against zero TRCV reads.

What this corrects

board-parts.md said the TDM port is "configured and then unused". The receive half is unused; the transmit half is one of the busiest things the DSP does. The scan behind that claim looked for TRCV reads and drew a conclusion about the whole port.

The receive half really is unused - and here is why that is not circular

The obvious objection to "zero TRCV reads" is that the harness never delivers a word on that port, so nothing could read one. That objection is correct about the runtime measurement, which proves nothing on its own - it is the same trap as the codec receive queue, where nothing arrived, so the firmware consumed nothing, so the model looked consistent with itself.

The static evidence is independent of it, and it agrees:

  • IMR is written exactly once, at 0x809e during reset, with 0x002a - INT2, TINT and XINT. TRNT is bit 6 and TXNT bit 7; neither is enabled anywhere in the 27,710-word resident, so an arriving word could not interrupt.
  • TSPC is written twice at reset and never read. Nothing polls RRDY on that port, so an arriving word could not be noticed by polling either.
  • TRCV is never read through MMR addressing anywhere in the resident.

The one direct-addressed candidate, lacl @30 at 0xaa4b, is not a register read at all:

aa4b  lacl @30 ; sub #4f52 ; retc neq     ; 0x4f52 = "RO"
aa4f  lacl @31 ; sub #4b43 ; retc neq     ; 0x4b43 = "CK"

That is an ASCII signature check - "ROCK" - against cells on some other data page, sitting in a chain of retc neq guards. It is not TRCV/TDXR.

So the link is one-way: DSP to ASIC. RRST is set in TSPC, leaving the receiver out of reset, but nothing in the firmware ever looks at what it receives.

Worth noting what the neighbouring routine at 0xaa30 does, since it lands on the same registers by coincidence: it writes @74, @75, @76, @77 with 0x0302, 0x0303 and 0x18, which are exactly the cells the idle task reads to build its TDXR word. So that is the configuration of what gets streamed out this port - two source pointers and a shift.

What it does not establish

The other end of the second port has not been traced, and nothing here shows the ASIC on it - that is the board observation, not a firmware result. Nor is it established what the packed byte pairs carry; they are two independently scaled values sent every idle pass, which is consistent with metering or control, but that is a guess.

What is firm: the DSP masters a serial link that it transmits on constantly, and the harness models that link as completely inert. queue_serial_rx feeds the primary port; nothing ever delivers a word on TRCV, and TDXR writes are counted and discarded. If the ASIC answers on that port, the emulator has never heard it - which is a candidate explanation for the DSP never leaving its idle task, alongside the ARCR gate in what-runs-and-what-blocks.md.