Files
courier-emu/docs/codec-rate-312.md
T
Cryan209andClaude Opus 5 fd0dcf0554 Find the rate table: 7200 is 2400 baud, and V.34 moves the codec
The contradiction in codec-rate-312.md was one false premise. The AC01's
divider registers are not written only at reset: a table-driven selector
immediately after the control-word sender inlines the sender's handshake
instead of calling it, which is why every scan for calls to the sender
missed it. Six rows, indexed by V.34's 3-bit negotiated symbol rate, write
register 2 with B = 20, 19 or 18 - 7200, 7578.95 and 8000 Hz.

The mapping is arithmetic rather than suggestive: word 2 of each row is
360 x baud / Fs for all six symbol rates, and B = 18 lands exactly on the
8000 Hz that V.PCM needs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 00:57:19 +12:00

15 KiB

The codec on the 3.1.2 board: DSP-driven, and not fixed at 7200 Hz

Resolved. The contradiction this document builds and leaves open is resolved in codec-sample-rates.md. The claim that fails is "the divider registers are written once at reset and never again": a second, table-driven routine at 8140 - immediately after the sender at 8138 - inlines the sender's handshake instead of calling it, and writes register 2 with one of 0214, 0213, 0212 (B = 20, 19, 18) as selected by V.34's negotiated symbol rate. The three sample rates are 7200, 7578.95 and 8000 Hz. Every scan recorded below looked for calls to the sender, which is why none of them found it. Everything else here stands.

Two claims are corrected here. This board's firmware does drive its TLC320AC01 from the DSP, and the 7200 Hz figure in audio-312-path.md is the dial path's rate, not the board's one sample rate.

The AC0x protocol is in this image

board-parts.md describes the part's protocol correctly - a TLC320AC0x pairs with a TMS320 serial port and uses bit 0 of the transmitted word to request a secondary control frame - and then concludes that the 20.16 MHz board "carries a TI AC01 whose own firmware never drives it from the DSP". That conclusion does not hold for this build.

The serial ISR is that protocol:

818d: lamm @6b      ; the secondary-frame request
818e: or   *+       ; OR it into the sample word
818f: samm @21      ; DXR

and 819e sends the control word from 006c in place of a sample. Reset programs six control registers through the sender at 8138, which parks the word in 006c, sets the request in 006b, and idles until the ISR has sent it:

call word
80a2 010a
80a6 0214
80aa 0300
80ae 0409
80b2 0505
80b6 0620

The earlier search was for main211's initialisation routine and its table, and correctly did not find them. This image has its own, different one. What that removes is the support for reading 1 there - "the ASIC fronts the codec" - for this board. The dxr_writes is 3 measurement that motivated it was taken on main211, whose DSP stops transmitting after reset; here DXR is written every sample at 818f.

Note also that document's program addresses for the 20.16 MHz build are this document's minus 0x8000: its TSPC setup "at program 0x008a" is the samm @32 pair at 808a here. The two are reading the same instructions.

7200 Hz is the dial path, and the dial path only

The rate was inferred from the keypad phase increments, and that inference is sound - but only for the code it was drawn from. Digit 1's increments give 696.97 Hz and 1209.05 Hz at 7200, within 0.05% of the DTMF pair, and nothing close at 8000, 9600, 11025 or 14400.

It is sound because DTMF tolerance is tight. At ±1.5%, the same increments under a 9600 Hz codec would emit 929 Hz and 1612 Hz and fail every detector. And the ISR consumes exactly one buffer word per codec interrupt, so while dialing the generator's rate and the codec's rate are the same number. The dial path really does run at 7200.

Which is what makes the figure unsafe to generalise. ATI7 on this unit advertises x2 and V90. V.PCM carries an 8000-baud carrier and cannot live under 7200 Hz sampling's 3600 Hz Nyquist; V.34+ at 3429 baud reaches about 3673 Hz and does not fit either. So the codec rate must change between dialing and those modulations. That is a consequence of two facts already established, not a hypothesis: either the rate is reprogrammed, or this board cannot do what its own identity string says it does.

7200 is a sensible base rate for what this firmware lineage originally targeted - V.32 and V.FC, comfortably inside the 300-3400 Hz telephony passband. The later modulations were added to the same codebase over the following years, and they are the ones that need the rate moved.

There is a runtime path to move it

8138 has seven call sites. Six are the reset constants above. The seventh is tag 2c's handler:

86de: lamm @7a      ; the host's mailbox argument
86df: b    8138     ; straight into the codec control-word sender

So one mailbox command writes an arbitrary 16-bit word to an AC01 control register at runtime. That is the mechanism a rate change would use.

Not established: that the supervisor uses it. See below.

What the senders carry

The supervisor has two enqueue paths, and the second one is why an earlier enumeration missed the dial tags:

path routine format
three-word f678 ff00, then tag in AX, then argument in BX
one-word f64c a single word, (tag << 8) | data

The one-word format is confirmed by the dial marker: sites load AX with 1600 and call it, which is tag 16 with argument 0, exactly as courier_firmware_analysis.md describes the dial conversation.

Both routines have far-call thunks at 0f644 and 0f648, and most callers use them. Resolving those needed the address mapping in flash-addressing.md; scanning for the offset field alone finds none, because the thunk is reached as 8f46:01e4. With it, the visible send sites go from 23 to 137:

path tags observed
three-word 02 0f 10 11 12 17 19 1a 1b 1c 1d 1e 1f 21 2a 2c 30 32 33 36 37 39 3b 3c 48 50 51 52 70 71 73 74 76 77 78
one-word 01 05 06 0a 0c 0e 15 16 2a 3d 3e 3f 40 41 43 44 4a 4b 4f 55

Five sites build the tag rather than loading it and are not in those lists.

Tag 2c is sent - but it does not carry the rate

Three sites send it, each mov ax, 0x2c immediately before the far call:

site argument
4a893 bx = 0405
4a8c1 bx = 0409
49a3c bh = 4, bl computed as two 2-bit fields, each forced non-zero

All three write register 4. None touches registers 1 or 2. And in the DSP image only the six reset sites call 8138 at all - a scan of every lacc #0nnn ; call 8138 pair in program 8000..f000 returns exactly those six.

So on this firmware the codec's divider registers are written once, at DSP reset, and never again. The runtime path exists and is used, but for register 4, whose two 2-bit fields look like gain rather than rate.

Which leaves a real contradiction

Closed. See codec-sample-rates.md: point 2 below is false. The paragraph that follows is kept as the record of how the question stood before the rate table was found.

Was still open. This was briefly marked resolved, on the grounds that the board reads samples on both C5x serial ports. It does not: overlay 6's apparent TRCV and DRR reads are a data table read as code, and nothing in any image reads TRCV at all. See the retraction in vpcm-datapump.md. The three facts below stand, they still cannot all be true, and the only sample path in evidence is the AC01.

Three things cannot all be true:

  1. The dial path runs at 7200 Hz. Constrained hard by DTMF tolerance, as above.
  2. Registers 1 and 2 are set once at reset and never changed.
  3. This unit does x2 and V.90, which need at least 8000 Hz. ATI7's option list is the enabled feature set, not what the build could do, so the x2 and V90 entries mean this board is licensed and expected to run them. The unit is labelled "COURIER V.34 Fax with V.32 bis", so V.PCM arrived as an upgrade to it - which puts a V.PCM datapump somewhere in this image.

Something in that list is wrong, and this document does not know which. The first candidate below has since been ruled out, which sharpens the problem rather than solving it: no payload the supervisor downloads reprograms the rate.

  • A second DSP program. Ruled out. Relaxing the download-site scan to the whole image and to any entry word - it was limited to the first code segment and to entry 8000 - finds three call sites, which is what rom.py already says this board has. All three send the same payload: entry 8000, flash 29140..36e8e, 28,327 words. There is no second download.

    There is, though, about 55 KB of further C5x code immediately after that payload, at 36e8e..~44633, which no download call references. It is real code and its internal call targets are consistent, but it contains no host sender (out *, 0060), no DXR write, and no codec initialisation - pure algorithm code with no I/O, which is what datapump overlays look like. It is loaded by a second, table-driven transfer routine - see dsp-overlays.md - as three images at program 9d00, b000 and dc00. Only one of them writes the codec at all, and that write is register 4 again, so the dividers are still untouched after reset.

    All three 512 KiB 20.16 MHz images - stock 7.3.14, ID_SDL 4.03, and the flat IDSDL302.ROM - carry exactly one codec initialisation, with byte-identical values 010A 0214 0300 0409 0505 0620. main211 differs (0203 0502 0670, register 2 = 03 against 14 here), which is consistent with it being the 25.8048 MHz build.

  • Register 4 is not only gain. If it carries a rate or filter select, the three sends above are the rate change and the reading of them is wrong.

  • The register numbering. The whole (register << 8) | data reading rests on the reset sequence looking like registers 1-6 in order, which is suggestive rather than decoded.

  • The AC01 is not the datapump's converter. This would reconcile everything: the part runs at 7200 Hz for dialing, call progress and voice, and the datapump's samples go somewhere else. It is a modified form of board-parts.md's reading 1, and the overlay region above is weak support for it - algorithm code with no I/O has to be fed by something. What argues against it is that the resident bank's ISR moves a sample every codec interrupt and there is no second sample path in this image.

What would settle it

Reading the six reset words as an actual sample rate needs the AC01 register map, which the repository does not have; board-parts.md already records that a guessed bit layout did not fit main211's table. Under the natural (register << 8) | data reading these are registers 1-6 with A = 10 and B = 20. If those are the usual dividers with Fs = MCLK / (2 * A * B), that is MCLK / 400, which needs a 2.88 MHz master clock to give 7200 Hz. The board's 20.16 MHz would give 50.4 kHz, which is out of range for the part, so either the register reading or the assumed master clock is wrong.

There is a way round the missing datasheet. The dial path's 7200 Hz is known independently, from the increments. So a second mode's register values, whatever they are, would give the ratio between the two rates directly - and with the Fs = MCLK/(2AB) form assumed, MCLK itself. Finding one tag 2c send with a known modulation would convert the whole question from a datasheet lookup into arithmetic.

Where the V.PCM datapump is not

Two searches for it came back empty, and one of them was the wrong search.

There is no companding table - no monotonic run of 48 words or more anywhere in the resident bank or the three overlays, and only one in the supervisor, which is not shaped like one. That is the expected result rather than a surprising one: the Courier works in the linear domain, so a mu-law table is not something its datapump needs, and this says nothing about whether V.PCM code is present.

There is also no line-probe tone table. V.34's probing signal is tones at multiples of 150 Hz, so a table of phase increments for it would be an arithmetic progression whose step gives the sample rate directly - 0x0555 at 7200 Hz, a round 0x0400 at 9600. No progression with a plausible step exists in any of the four images, so the probe is synthesised some other way and that route to the rate is closed.

What the tag 46 window actually streams

The table it reads from, at program 85f2, is the V.34 rate and carrier table:

words meaning
0708 0725 074b 0753 0780 07a7 1800, 1829, 1867, 1875, 1920, 1959 - V.34 carrier frequencies
0960 0ab7 0af0 0bb8 0c80 0d65 2400, 2743, 2800, 3000, 3200, 3429 - all six V.34 symbol rates

artifacts/dsp-window-pump-02/ and -03/ describe these as "DSP program memory matching the flash image at addresses predicted beforehand", which is true and was the point of that run, but under-reads them. The window reports which V.34 carrier and symbol rate the datapump is using.

They are stored as decimal Hz and baud, not as phase increments, so they carry no sample-rate information themselves.

Every way out, and why each is shut

The contradiction has survived a lot of searching, and what follows is the list of resolutions that have been tried and closed, so none is attempted a fourth time.

way out why it is shut
A second DSP program with its own codec setup Three download call sites, all sending the same payload. See dsp-overlays.md
An overlay reprogramming the dividers Only the six reset writes call the control sender at all, and the one write an overlay makes is register 4. This is where the answer was: the rate selector at 8140 does not call the sender, it inlines it - see codec-sample-rates.md
Tag 2c carrying the rate at runtime It is sent, three times, and every one writes register 4
A second converter on the TDM port Retracted. Nothing in any image reads TRCV; the apparent reads are a data table
Samples arriving over external I/O instead With the anchoring filter applied, the overlays have no real in/out at all, and the resident's are mailbox, window and codec-control ports. There is no 0x50/0x52/0x54 sample loop in this image
An interpolator between the tone generator and the codec The main loop at 80c3 is a producer/consumer against the ISR's own pointer - lar ar0, @10 ; cmpr eq ; bcnd - producing exactly one output word per callback and stopping when it catches up. One sample per interrupt, no resampling

So the only sample path anywhere in this image is the AC01 on the primary serial port, moved one sample per interrupt by the resident ISR, at a rate the dial path's DTMF pins to 7200 Hz, set once at reset and never changed.

Two candidates are left, and neither can be settled from the image alone:

  • The divider registers do not mean what is assumed. The whole A = 10, B = 20, Fs = MCLK / (2AB) reading rests on the reset sequence looking like registers 1-6 in order. That needs the AC01's register map.
  • Something in the DTMF chain is wrong. It is short and each link has been checked - a 16-bit phase accumulator at 8743, one sample per interrupt at 80c3, sixteen increment pairs whose ratios are DTMF's - but it is the only thing pinning the rate.

The second is testable without a datasheet, and cheaply: record the modem dialling and measure the tones. If they are 697 and 1209 Hz then the codec runs at 7200 during dialling and the contradiction is real and unexplained. If they are not, the chain breaks at a link that measurement will identify. That is the physical recording attempt audio-312-path.md records as abandoned, and it is now the cheapest experiment left rather than a loose end.