本页尚未翻译,目前显示英文。
DMR modem behavior and the dmr_modem HAL contract
What a fresh DMR Tier II stack must do on top of any baseband modem (Hongrui HR_C6000, HR_C7000, HR_C5000, a
future software modem), and the interface a modem driver offers it. Protocol facts are from ETSI TS 102 361-1 (air
interface), -2 (voice and generic services) and -3 (packet data); clause numbers are given where useful. Modem
facts come from modem-hrc6000.md (HR_C6000) and modem-hrc7000.md (HR_C7000), and are marked as such. Which radios
carry which modem, and what has been checked on each, is in feature-matrix.md.
Terms: slot = one 30 ms TDMA timeslot; frame = two slots (60 ms); superframe = six voice bursts A-F on one slot (360 ms); inbound = MS to BS (repeater input); outbound = BS to MS; RMO = through a repeater, DMO = direct mode (no repeater).
1. Air interface facts the stack relies on
1.1 Physical layer (TS 102 361-1 clause 10)
- 4FSK, 4800 symbols/s, 9600 bit/s gross, 12.5 kHz channel. Deviation +-648 / +-1944 Hz (dibits 01/00/10/11 map to +3, +1, -1, -3).
- One slot carries one burst: 264 bits (27.5 ms) plus 2.5 ms that is either the CACH (BS outbound, 24 bits) or guard time for the PA ramp (MS inbound, and direct mode).
- The modem does symbol timing, sync search, burst framing and FEC. The stack never handles symbols.
1.2 Burst layout (clause 4.2, 6)
| Burst | First half | Middle 48 bits | Second half |
|---|---|---|---|
| Voice with sync (burst A) | 108 bits AMBE | voice sync | 108 bits AMBE |
| Voice with embedded signaling (B-F) | 108 bits AMBE | 8 EMB + 32 embedded signaling + 8 EMB | 108 bits AMBE |
| Data / control | 98 bits info | 10 slot type + 48 data sync + 10 slot type | 98 bits info |
- Voice payload: 216 bits = three 72-bit AMBE+2 frames (20 ms each, with their FEC). The modem drivers exchange it as 27 bytes.
- Slot type: color code (4) + data type (4) + Golay(20,8) parity.
- EMB: color code (4), PI (1), LCSS (2), QR(16,7) parity.
- Data info: 196 bits = BPTC(196,96) for 96-bit payloads (rate 1/2, headers, CSBK, LC), trellis rate 3/4 for 144-bit payloads, no FEC for 192-bit rate 1 payloads (rate 1 fails on any single bit error).
1.3 Sync patterns (clause 9.1.1)
| Source | Voice | Data |
|---|---|---|
| BS | 755FD7DF75F7 | DFF57D75DF5D |
| MS | 7F7D5DD57DFD | D5D7F77FD757 |
| TDMA direct mode TS1 | 5D577F7757FF | F7FDD5DDFD55 |
| TDMA direct mode TS2 | 7DFFD5F55D5F | D7557F5FF7F5 |
| RC (MS) | 77D55F7DFD77 |
The receiver must accept MS, BS and both direct mode sync families (and say which one it heard): BS sync means a repeater's outbound; MS sync is used both inbound to a repeater and, by most radios, in simplex; TS1/TS2 sync is TDMA direct mode (dual capacity direct mode, DCDM, and some SFR framings).
1.4 Data types (slot type, clause 9.3.6)
| DT | Burst | Payload |
|---|---|---|
| 0 | PI header | 96 bits (privacy) |
| 1 | voice LC header | 72-bit LC + RS(12,9) with mask 0x969696 |
| 2 | terminator with LC | 72-bit LC + RS(12,9) with mask 0x999999 |
| 3 | CSBK | 80 bits + CRC-16 mask 0xA5A5 |
| 4 / 5 | MBC header / continuation | 80 bits + CRC-16 mask 0xAAAA (last block: CRC over the whole MBC) |
| 6 | data header | 80 bits + CRC-16 mask 0xCCCC |
| 7 | rate 1/2 data | 96 bits |
| 8 | rate 3/4 data | 144 bits |
| 9 | idle | 96 bits |
| 10 | rate 1 data | 192 bits |
| 11 | unified single block data | 96 bits |
| 12-15 | reserved |
PI header CRC mask: 0x6969.
1.5 Full LC (TS 102 361-2 clause 7.1.1)
Nine bytes: FLCO + PF (byte 0: protect flag bit 7, FLCO bits 5-0), FID (byte 1), service options (byte 2), destination (bytes 3-5), source (bytes 6-8). FLCO 0 = group voice, 3 = unit to unit (private). Service options: bit 7 emergency, bit 6 privacy, bit 3 broadcast, bit 2 open voice call mode, bits 1-0 priority. Embedded data uses other FLCOs: 4 talker alias header, 5-7 talker alias blocks 1-3, 8 GPS info (TS 102 361-2 7.1.1.3-7.1.1.4).
1.6 Timing structure
- Slot 30 ms; frame 60 ms (TS1 then TS2); a talker on one slot sends one burst every 60 ms.
- Superframe: bursts A (sync) and B-F (EMB) = 360 ms. The embedded LC (72 bits + 5-bit checksum, BPTC(128,77)) is spread over bursts B-E as 4 x 32 bits (LCSS 1 first, 3 continuation, 2 last); F carries null embedded data, the reverse channel or privacy information. The color code and PI are in every EMB.
- CACH (BS outbound only): 24 bits per slot: TACT = AT (1), TC (1), LCSS (2) + Hamming(7,4) parity; 17 bits of a
short LC fragment. TC says which timeslot follows (0 = TS1, 1 = TS2): it is the only way an MS learns the slot
number. AT (access type) says whether the inbound slot that starts one slot later is busy (1) or idle (0)
(-1 4.5 figure 4.8). Repeaters run aligned timing (-1 5.1.1, table 5.1: a subscriber on TSx transmits under
outbound TSx), so the AT before outbound TSx is the other channel's: an MS on TSx reads its busy state from the CACH
before the other outbound slot (
split-duplex.md5.2 and 7). - Voice call on air: one or more voice LC headers (DT 1), optionally a PI header (DT 0) for privacy, then superframes, then one or more terminators with LC (DT 2). Calls should end at a superframe boundary (after F).
- Repeater outbound: continuous while active; after a call the repeater keeps the outbound up for the hang time (idle bursts / terminators with the call's LC), then drops it.
1.7 Channel access (TS 102 361-1 clause 5.2)
| Policy | Rule before transmitting |
|---|---|
| impolite | transmit regardless |
| polite to own color code | don't transmit while the channel carries our CC (other CCs are ignored) |
| polite to all | don't transmit while the channel carries any DMR or RF activity |
Through a repeater, "busy" is the AT bit for our channel (in the CACH before the other outbound slot, above), plus decoded activity on our slot. In direct mode, "busy" is decoded activity with our CC (or carrier, for polite to all). A data or voice transmission that waits for the channel must time out (a few seconds, configurable) rather than wait forever.
1.8 Soft decision decoding of BPTC(196,96) (core/dmr/fec/dmrSoftBptc.h)
A receiver that has a reliability for each bit (a sample tap through the soft modem, or a modem's soft symbols) can
decode bursts the hard decoder gives up on. The hard decoder (dmrFecBptcDecode) corrects one error per row and column, columns and rows at once on the packed matrix (one 16-bit word a row, the column syndromes as four XOR sums); the soft decoder
weighs each bit by how sure the receiver is of it.
| Item | Rule |
|---|---|
| Input | One LLR per info bit in burst order (bits 0-97, then 166-263), positive for a 1, in eighths of a natural log ratio, clamped to +-127 |
| Scale | Exact only for true LLRs: the caller scales by its own noise estimate. For 4FSK sliced at +-2 with noise variance s2 (symbol levels +-1, +-3): the first bit of a symbol v has LLR -2v / s2, the second -2(2 - abs(v)) / s2 |
| First step | The hard decisions go to the hard decoder. A burst that decodes and passes accept costs no soft work (returns 0) |
| Iterations | Each one decodes every row (Hamming(15,11)) and then every column (Hamming(13,9), shortened), soft in and soft out, exactly over the 16 words of the code's dual (Hartmann-Rudolph). The extrinsic LLRs of one pass feed the other |
| Stop | After each iteration the decisions go to the hard decoder; its payload ends the decoding once accept takes it. Default 4 iterations at most (DMR_SOFT_BPTC_ITERS: on Gaussian noise 98 % of what 20 decode) |
| Accept | The payload's own check (CRC-CCITT with the data type's mask, or the LC's Reed-Solomon). Required: after the first iteration, a codeword the hard decoder reaches is often wrong |
| R(3)-R(0) | R(3) is outside every codeword and comes from its own decision; R(2)-R(0) sit in row 0's codeword and are read from the final decisions |
| Arithmetic | Fixed point, no divide: tanh(L / 2) from a table in Q31, products in Q31 through fxp_mulhr (core/dsp/fxp.h: one instruction on a core with a 32 x 32 multiply), sums in Q27, the log ratio from a log2 table. Q15 is not enough: for a row of sure bits that disagree, the two sums cancel to 1e-4 or less |
| Cost | A row or column: the 15 dual-code words' products by groups of four columns (63 products, no branches), one 16-point Walsh-Hadamard transform for every bit's sums, then one product and two table logs a bit. On a 72 MHz Cortex-M4: about 1,900 cycles a row and 1,700 a column, 81,000 for a hard try, one iteration and a hard try; 282,000 for 4 iterations that fail. Work memory 588 bytes, owned by the caller |
| Memory | The tables (about 0.6 KB) go to CPU-only RAM where the platform has some (RFOUNDRY_CPU_DATA, core/config.h); the work memory should too (RFOUNDRY_CPU_RAM). Built -O2 (HOT_SRC in the Makefile) |
Gain over the hard decoder on Gaussian noise (the host test, 1000 bursts at sigma 0.85 on +-1): hard decoding 3 %, soft decoding 75 % with 4 iterations at most, no wrong payload accepted.
2. Mobile station states
+--------- carrier / sync lost (timeout) ----------+
v |
IDLE (listen) --sync+CC--> RX_SYNCING --slot locked--> RX_VOICE / RX_DATA --terminator / timeout--> IDLE
| |
| PTT / data queued | PTT while hearing repeater hang time
v v
[RMO, repeater not heard] --> BS_ACTIVATION --repeater heard--> TX_ALIGN --> TX_HEADER --> TX_VOICE --> TX_TERMINATOR
[RMO, repeater heard / DMO] -------------------------------------^ \--> TX_DATA ---------------^
|
HANG (listen on own slot) <---------+
This is a behavioral diagram, not a structure to copy. The states and what they require:
2.1 Idle / listen
- The modem receives every slot (no slot lock yet), with sync detection for all four families.
- Color code: either fixed (only bursts with the channel's CC are deframed) or "follow": accept a new CC when it is seen repeatedly (HR_C6000 practice: 8 consecutive matching reports, under 200 ms apart, with an SNR margin of 5 dB or more; held while audio is heard, released after 5 s idle).
- A burst with matching CC moves to RX.
2.2 Receiving
- Mode detection: BS sync => RMO reception (slot number from CACH TC). MS / TS1 / TS2 sync => DMO reception (unless the channel forces DMO, or the radio is an SFR user/repeater, which stays DMO).
- Slot lock (RMO): track TC; a stable count of agreements (more than 4) gives the slot phase; then receive only the wanted slot. Too many disagreements (more than 3) => resync. If the slot filter is off, the "captured" slot is the first one carrying a call; after the capture timeout of silence on it, try the other slot.
- Slot lock (DMO): lock to the slot of the first valid burst; receive one slot in two.
- Filters applied to every burst: color code; timeslot (RMO, if the slot filter is on); destination (talkgroup / receive group / private call to us / all call 0xFFFFFF passes everything); privacy indicator (bursts with PI set are only played when privacy is configured for that call).
- Start of call: a voice LC header with good CRC, or late entry (2.4). Do not announce the caller from the LC until it is known to be this call's (modems may hold the previous call's LC: see 2.4).
- During voice: every burst A-F is handed to the vocoder in order; a missing burst is replaced by silence; the embedded LC is re-checked each superframe (the talker may change between overs on a repeater without a header).
- End of call: terminator with LC (DMO only: through a repeater, the MS hears its own terminators echoed and must not end its next reception on them; use the timeout), or no valid burst on the slot for about 390 ms (13 slot ticks), or loss of slot timing.
- Data: CSBK, MBC, data headers and blocks on our slot are passed to the data service. Blocks are taken even with
a CRC error (the packet CRC-32 decides). Headers and CSBKs with a bad CRC go up flagged too (
crc_okfalse; for a voice LC header or terminatorlc_validfalse, and no call state changes): the receivers drop them, unless the channel is set to accept an invalid CRC (dmr-trunking.md 6, dmr-voice.md).
2.2.1 Soft combining
A control channel sends the same few CSBKs over and over. A CSBK, MBC or data header whose CRC failed is decoded
again from the modem's soft values, summed with the earlier copies (core/dmr/fec/dmrSoftComb.c, built with
DMR). Modems that give soft values per info bit take part; the others pass bursts up as before.
| Step | What |
|---|---|
| Stage | On reception, the driver copies the burst's 196 soft values (int8, positive for a 1) to a staging buffer. Only for the burst types above with a failed CRC |
| Join | At task level the burst joins the set of its slot whose hard bits are within 50 of its own; else the burst replaces the empty or longest unused set. 4 sets per slot. A set halves after 6 bursts, so a message that changes is followed |
| Decode | BPTC on the joined set. A burst that joined no set keeps the chip's payload |
| Choose | The chip's payload and the set's decode are re-encoded (with the reserved bits R(3)-R(0) the decode found) and scored against the set's sums. The set's decode replaces the chip's payload only on a higher score |
The burst's own BPTC decode is not a candidate: through heavy noise BPTC miscorrects to a codeword that fits one burst's soft values better than the chip's right decode (the chip decodes with soft values of its own).
crc_ok stays false: the receivers check the CRC of what they take, and a channel set to accept an invalid CRC takes
a payload only on a repeat. A wrong decode doesn't repeat, since the sets keep changing.
The sums live in about 2 KB that the modem glue allocates when DMR starts and frees when DMR stops.
Counters: soft in the modem's diag line (taken, combined, changed, stale).
2.3 Repeater mode vs direct mode timing
| RMO | DMO (simplex, MS sync) | DMO (TDMA direct, DCDM) | |
|---|---|---|---|
| Who sets the slot clock | the repeater (CACH, outbound bursts) | the first talker; the receiver follows its bursts | the first talker; both slots usable |
| Slot number known from | CACH TC | not known (only "the slot heard") | sync family (TS1 / TS2 sync) |
| Our TX slot | the channel's TS, aligned to the outbound | the slot phase we start in, or the one heard (reply aligned to the talker) | the channel's TS, aligned to the other slot's traffic if heard |
| Busy from | AT bit + decoded traffic | decoded traffic | decoded traffic on our slot |
| End of call | timeout (echoes) | terminator or timeout | terminator or timeout |
| Modem timing mode | passive (follow received) | active (own) when starting, passive when receiving | passive when the other slot is busy, otherwise active |
A single-frequency repeater (SFR, ERDM) user is DMO framed but must transmit in the slot opposite to the one it hears from the repeater, aligned to it (see the SFR spec). The modem must therefore support "start transmitting in the slot after the next one, in phase with the bursts being received".
2.4 Late entry
- A receiver that missed the header acquires the call from the embedded LC: needs bursts B-E of one superframe, so 360-720 ms after the first burst heard.
- Some modems announce it (HR_C6000: post-access interrupt), others only report voice bursts with embedded LC. The stack must handle both: voice bursts with no preceding header start a call once the embedded LC is complete.
- Stale LC: the HR_C6000 (and likely the C7000) keeps the previous call's LC in its RX LC buffer until a new one is decoded. The stack must not attribute the new call to that LC: either wait two superframes (two bursts A) after the slot lock, or compare with the LC that was present when the reception began and only accept a different one, or accept after more than one superframe. This is the driver's job, done once: it knows its chip's buffer, and a voice burst's embedded LC marked valid is this reception's (6.1 rule 4). The HR_C6000 driver captures the buffer when a reception starts and accepts an unchanged LC after more than one superframe of voice; the HR_C7000 hands over only LCs its late-LC interrupt reports with a good checksum. The stack must not add its own stale check on top (for example against the previous call's LC): the same talker calling again then costs a superframe more for each layer (HIL 2026-10-10: a late entry joined at burst 9 of 36 played 7 bursts instead of 13).
- Skip the first two bursts A of a late entry before playing audio, unless the source is already known and isn't us.
- A call that faded (no terminator) and comes back within 1.5 s (
DMR_CALL_RESUME_MS) with the same LC, on the same slot, is one call with a hole in it: the sink sees it end and begin,rx_callscounts it once andrx_calls_resumedcounts the return. The LC reaching the stack is still the driver's to prove: an LC in a sticky buffer doesn't show the same call is on air (modem-hrc6000.md 5.6). - A lone voice burst (noise, a stray) must not start a call: require a B 60 ms after an A (SFR practice). An LC that comes with the first burst is held with that burst until the next burst makes the pair, then both are played. The HR_C7000 reports voice only once it has the LC, so its first burst carries it (HIL 2026-10-15: dropping that LC cost a superframe, 13 bursts played instead of 18).
- A PI header missed => privacy parameters come from the embedded / F-burst privacy info (risk for privacy schemes).
2.5 Transmitting voice
The call stack configures the modem with the channel's transmit color code even when the receive filter accepts
any CC (any-CC listening, polite-to-all access, or a dual-CC SFR user). set_cc_filter changes reception only.
The CC fields are defined by TS 102 361-1 9.1.2 (EMB), 9.1.3 (slot type) and 9.3.1 (CC).
- Channel access per the policy (1.7). Busy => wait (with timeout) or refuse.
- RMO, repeater not heard: BS activation (2.7).
- Alignment: RMO: wait until the slot tracking is stable, then transmit in the slot after the next one that carries our TS. DMO: start on the modem's own timing; if a call is being heard (a reply), align to it.
- Headers: three voice LC headers on our slot (one per 60 ms: 180 ms of lead-in). Optionally a PI header for privacy schemes that need one.
- Voice: superframes A-F; burst A has the voice sync; B-E carry the embedded LC (or talker alias / GPS embedded data in alternating superframes); F carries null embedded or privacy data. If the encoder has no frame ready, send AMBE silence (B9 E8 81 52 61 73 00 2A 6B per 20 ms frame).
- End: PTT release takes effect at the next superframe boundary; send the terminator with LC on our slot.
- Hang: after transmitting, hold the slot on our TS (capture timeout) so the reply is heard on it.
- TX timeout timer (user setting) forces the end.
2.6 Transmitting data and CSBK
- A list of bursts (CSBK preambles, data header, blocks; or single CSBKs) goes out one per frame on our slot. No
voice header, no terminator. Same channel access and BS activation as voice. Up to 64 bursts per transmission
(
DMR_DATA_MAX_BURSTS); a timeout of 10 s + 60 ms per burst covers a wake-up. - The data service needs a "send this payload verbatim, I supplied the CRC" option (raw passthrough of CSBK / data headers from a host). On modems that always compute the CSBK / data header CRC (HR_C7000, HR_C5000), raw passthrough of a burst with an intentionally wrong CRC is not possible; the stack must then give the payload without its CRC and let the modem add it.
2.7 BS activation (repeater wake-up)
- Send a BS_Dwn_Act CSBK (CSBKO 0x38, LB=1, FID 0, BS address 0 = any, source = own ID). Octets: B8 00 00 00 00 00 00
- source (3). HR_C7000 practice: in two consecutive slots with the PA keyed; HR_C6000 practice: one burst.
- Then listen: the repeater is up when its outbound is heard with the slot number toggling correctly more than 3 times in a row.
- No answer within 600 ms: send again, up to the configured number of attempts; then report failure to the user.
- The CSBK goes on our own timing (
DMR_TIMING_OWN): no repeater is heard, so there is nothing to align to. On the timing the modem last had, from a repeater that had just dropped, the HR_C6000 sent nothing: its passive timing had no repeater left to follow. A CSBK whose transmission ends without going on air (DMR_EV_TX_DONEwith noDMR_EV_TX_SLOT_STARTED, the modem no longer sending) is sent again at once, as the next attempt (call.tx_wake_lost). - While a key-up waits for its first slot (the wake-up queued, or the aligned voice start not yet on the air), the modem's slot numbers don't count as the repeater heard: the modem labels slots from the timing it last had, which kept a repeater that had dropped "up". A repeater that dropped as the hang ended then got no wake-up.
- A voice start through a repeater that the modem gives up before its first burst (
DMR_EV_TX_REJECTEDorDMR_EV_TX_DONEwith nothing sent: no slot timing to align to) wakes the repeater again instead of being refused: once per key-up, and only while PTT is held, with the whole wake-up's attempts. A second such start is refused. The refused start's ownDMR_EV_TX_DONEcomes after its rejection, so a wake-up waits for its CSBK'sDMR_EV_TX_SLOT_STARTEDbefore taking aDMR_EV_TX_DONEas its own. - Where the modem reports the repeater's bursts (received, or heard between ours), only those say it is up; its slot numbers don't. They run on from the timing it last had, so a repeater that had dropped counted as up for a key-up 0.6 s later, and a second wake-up counted as answered by them.
- Our own ID as the source while a key-up lasts is our echo: the repeater replays an over it heard while down once a wake-up starts it. It never makes the channel busy.
- A start through a repeater that never gets a slot (no timing at all, so the modem's own wait never runs out) is cut by the stall timeout; it wakes the repeater again as above instead of being refused.
- A short PTT press still runs the whole wake-up (the user only starts the call; other radios do the same). On release the
stack keeps listening and retrying. If the repeater answers after release, nothing is sent and the call view's
wake_admitscounter goes up, so the radio plays its talk permit tone. If no repeater is heard in the last attempt, the call ends withDMR_TX_ERR_NO_REPEATERand the radio plays its deny tone.
2.8 Hang time and TX hold-off
-
The repeater can drop under our over: its hang ended just as we keyed, and it took our voice as nothing. Learning its hang to predict that is not general (hangs differ per repeater and per call type), so the stack reacts instead. Where the radio's RF can receive the repeater's outbound between our bursts on a split channel (the modem's
tx_listen_split;DMR_CALL_TX_LISTEN,dmr_call_set_tx_listen), a voice over through a repeater listens there. A repeater burst is BS sync on our color code: a neighbor's on another one (heard where the modem doesn't filter the color code) is not ours. No repeater burst forDMR_CALL_TX_DROP_MS(240 ms) once our bursts are on the air means it dropped (call.tx_rpt_drops): the over ends with a terminator, not an abort (an abort mid-voice left the next CSBK undecodable on the HR_C5000), the repeater is woken again (2.7, once per key-up) and the voice starts again. After that wake-up only the repeater's own bursts count as its answer. Before our first burst the same holds: an aligned start waits for the repeater's slot, and one that dropped as we keyed (its last bursts taken as up, or as the answer to our wake-up) gives none. With no repeater burst forDMR_CALL_TX_START_DROP_MS(540 ms) since the start, the start is aborted and the repeater woken, not left to the modem's own 1.5 s timeout, longer than a short key-up. Longer than under the over: after our wake-up the HR_C5000 at times hears nothing of a repeater that is up until the modem searches again (every 240 ms, modem-hrc6000.md 5), so the modem gets two searches first.call.rx_in_txandcall.rx_bs_in_txcount what was heard while sending. A radio whose RF can't (the modem'stx_listen_splitNULL or false) sends as before and doesn't see the drop. Nor does a modem that hears the repeater in only some of the listen slots, at times none for seconds (tx_listen_gaps): it listens for the RC only, and silence there is not a drop. -
Reverse channel (ETSI TS 102 361-1 5.1.5, 6.4.2; TS 102 361-4 6.4.14, 6.4.15.2): a radio that listens between its bursts also hears an RC the BS sends on the other slot, either a dedicated RC burst or one in voice burst F (EMB LCSS 00, PI 1). The modem reports its 11 RC info bits (
DMR_EV_RC,DMR_RC_EMBEDDEDfor burst F); the stack checks the CRC-7 (dmrFecRcInfoDecode). A cease command (0100) or cease request (0101) heard twice withinDMR_CALL_RC_CONFIRM_MS(1 s) while our voice goes out ends the over after burst F with a terminator, like the TX time-out:tx_errorceased, PTT released before the next over. Twice, because burst F's null fragment passes the CRC one time in 128, and the BS repeats an RC every 360 ms. A request is always accepted. Power commands (0000-0011) are only counted: the power stays as set.call.rc_good,call.rc_bad,call.rc_ceased,call.rc_lastin the diagnostics and thedmr_callview section. The HR_C6000 engine reads the RC info from 0x53 / 0x54 at a class 3 report, or a burst F report with LCSS 00 (hrc6000-registers.md 2.2). A dedicated RC burst has no sync, and the chips report nothing for it. After each listen slot the engine reads the chip's receive tap instead (the HR_C5000 and HR_C6000:hrc_chip_ttap_addr,tap_field; the HR_C7000: modem-hrc7000.md 5.4): the burst received, a voice-layout burst's 48-bit sync / EMB / RC field first. It decodes the field (dmrFecRcFromField) when its EMB has our color code, PI 1 and LCSS 00. Only an area that changed since its last read is decoded, and none the chip reported itself in that listen slot, so one burst counts once.rctin the modem diagnostics: RCs found / areas changed. -
Repeater call hang time: the repeater keeps the outbound up after a call; an MS that keys in it does not need BS activation and should reply on the same slot (and talkgroup, if group hang applies).
-
After hearing a call on our slot, a polite MS waits for the terminator / timeout before keying; an impolite one keys at the next aligned slot.
-
Talk permit before keying (
dmr_call_config_t.permit_hold_ms): on a radio whose beeps can't sound on air, an admitted voice call (the channel free, the repeater up) waits inTX_PERMIT, still receiving, while the radio plays its talk permit tone. It keys after at leastpermit_hold_msand oncepermit_busy()is false, at mostDMR_CALL_PERMIT_MAX_MS(400 ms) after the hold began. The call view counts each hold inpermit_seqand shows it as its own phase (DMR_CALL_PHASE_TX_PERMIT; the screen says ADMITTED). Releasing PTT in the hold ends the call, as in TX access. A call heard in the hold sends it back to TX access, as if it had been there at PTT: it is refused, or waits outaccess_wait_msand holds again with a new permit. Through a repeater the key-up is impolite, so without this it would go over the call. -
After our own transmission, the receiver keeps the slot lock and the call's destination for the capture timeout.
3. Privacy hooks
- Basic privacy (Motorola-style, Anytone 16-bit): the voice LC carries the privacy bit (service options bit 6) and a manufacturer FID; the AMBE bits of each burst are XORed with a key-derived pattern that depends on the burst position (A-F). The modem must give the stack the raw 27-byte AMBE before decoding and take raw AMBE for transmission, with the burst position. The EMB PI bit is set on voice bursts of an encrypted call.
- Receivers without the key: drop bursts with PI set (do not play them).
- Enhanced / AES schemes: need a PI header (DT 0) before the voice and the per-superframe privacy information in burst F. The modem must let the stack send a PI header burst and set the burst F embedded content, or at least pass them through. Late entry needs the IV from burst F (not supported by the HR_C6000 path today).
- The HR_C6000 has its own "end-to-end encryption" interrupts (TX-start sub-status bit 5); not used.
4. Talker alias and embedded data
- TX: in alternate superframes, replace the embedded LC with one talker alias block (the header, FLCO 4, carries the format and length and the first 6 characters; blocks 1-3, FLCO 5-7, carry 7 characters each) or a GPS embedded LC (FLCO 8, 25-bit longitude scaled 2^25/360, 24-bit latitude scaled 2^24/180). The modem must accept a new embedded LC per superframe.
- RX: the modem reports each assembled embedded LC (FLCO 0, 3, 4-8) once per superframe; the stack assembles the alias and decodes the GPS.
5. What the modems provide
| HR_C6000 | HR_C7000 | HR_C5000 | |
|---|---|---|---|
| Host interface | external chip; config SPI (page/register) + voice SPI + I2S | on-chip peripheral of the CK803S SoC, memory-mapped 32-bit registers | external; like the C6000 but config page 0 |
| Interrupts | timeslot, system, RF TX (RF RX not routed on the STM32 radios) | system (vector 61), TX timeslot (62), RX timeslot (63), RF TX (64) | timeslot, system, RF |
| RF TX lead | not measured | 3.1 ms before the burst with its RF control register at 0x41F1A (1.0 ms with 0x40A0A) | |
| PA off | MCU, at the next timeslot interrupt (>20 ms after on) or a 29 ms one-shot | one-shot timer, 28 ms default (user setting) | 30 ms timer |
| Burst status | one byte: data type / voice A-F (1-6 + voice bit), sync class, CRC flag, PI; separate CC/CACH and sync type registers | one 32-bit word: data type bits 11-8, voice type bits 14-12, sync class bits 1-0, error flags bits 30-24 | similar to the C6000 |
| Reports per voice burst | two (EMB, then burst) | the manual's EMB report exists too | |
| CRC of CSBK / data header | chip or MCU (CRC_MCU_Control) | chip only | chip only |
| Vocoder | AMBE on the MCU (binary blob), PCM over I2S | AMBE blob run in place from flash, tables in modem RAM | AMBE on the MCU |
| Timing modes | passive / active per register; "send next slot" / "receive next slot" / "resync" per slot | same model (LAYER2 control / TX-RX control / slot-on registers) | same model |
| RX restart | TX+RX enable passive, then sync-fail, clear, sync-fail, receive-next | slot-on off, sync-fail, receive-next, slot-on (RX+TX) |
Common model across all three: the host decides, at each slot boundary, what the slot after next does (send a burst of a given type, receive, or nothing), and the chip frames, codes and times it. That is the model the HAL keeps.
6. The dmr_modem HAL contract (proposal)
The driver owns the chip, its interrupts and the per-slot register work. The DMR stack owns calls, filters, policy and the data service. They meet through queues and events so that the stack runs at task level, never inside the slot interrupt.
6.1 Principles
- The driver keeps the slot clock. It numbers slots with a free-running counter and, when known, the TDMA slot (TS1/TS2) and whether we are in step with a received signal.
- Lookahead TX queue. The stack queues bursts ahead of time, each tagged with its target (our slot / a given slot number). The driver pops one at each of our slots and sets it up from its own interrupt. Deadline for the stack: a burst for slot N must be queued before the boundary of slot N-1 (30-60 ms ahead). An empty queue in the middle of a voice call means "send AMBE silence"; in data, "end of list".
- RX bursts are copied out by the driver in the interrupt (the modem buffers are overwritten every slot) and delivered as events; the stack has no hard deadline beyond the queue depth (at least 8 bursts).
- The driver de-duplicates modem quirks: one report per burst (drops the C6000's EMB double report), voice burst index 0-5, CRC flag normalized, stale LC flagged.
- "Transmitting" is the driver's slot state, from the first burst set up to the end of the last burst's slot, never the PA state (the PA switches per burst).
6.2 Events (driver to stack)
| Event | Contents | Timing |
|---|---|---|
slot_tick |
slot counter, TS if known (from CACH TC or sync family), what this slot is (ours TX / RX / none), CACH AT (busy) if heard | every 30 ms; delivered within 2 ms of the boundary; informative (the stack must not need to answer it in time) |
burst_rx |
kind (voice A-F index / data type / LC-only), sync family (MS/BS/TS1/TS2), color code, CRC ok, PI, TS if known, in-step flag (report 2-10 ms after the boundary), RSSI if available, payload (LC 9+3 bytes, data 12/18/24 bytes, voice 27 bytes + the embedded LC if complete) | within 10 ms after the burst's slot ends |
call_acquired |
late entry announced by the modem (optional; the stack must also work without it) | |
voice_lost |
voice sync lost on a slot (the next voice frame should be silence) | |
tx_slot_started / tx_slot_ended |
per transmitted burst (RF keyed / unkeyed), for diagnostics and RF switching on boards where the driver doesn't own it | at the RF TX interrupt / PA off |
tx_rejected |
the modem refused to send (channel busy under a polite policy) | |
tx_done |
the last queued burst's slot has ended (terminator included); the driver is back in receive | after the last burst's slot, not before |
sync_lost |
no slot tick for 200 ms while not idle, or the timing was found out of step; the driver has restarted the receiver | |
short_lc |
a BS's CACH short LC (ETSI TS 102 361-1 7.1.4) as the chip assembled it: 28 bits and the CRC-8 received. The stack checks the CRC (dmr_call_short_lc). Optional: only while both slots of a BS signal are received (a trunked control channel), from chips whose short LC location is known |
when it changes; a new one every 120 ms |
6.3 Commands (stack to driver)
| Command | Effect |
|---|---|
configure |
own DMR ID, channel's transmit color code and initial receive filter, sync families to detect, default access policy (impolite / polite to CC / polite to all), DMO / RMO framing |
rx_start / rx_restart |
receive every slot, passive timing; restart = drop sync and search again. The radio core restarts at every new DMR frequency with the stack running (a scan or channel step): a chip may keep the last transmitter's slot timing otherwise (gotchas 17.2) |
rx_lock_slot(slot or none) |
receive only our slot / both |
tx_begin(timing) |
start a transmission: own timing (DMO), aligned to the received signal on the next slot carrying a given TS (RMO, SFR user), or as soon as possible; with the access policy for this transmission |
tx_queue_burst |
one burst: type (voice header, voice A-F with 27-byte AMBE, terminator, PI header, CSBK, data header / block, idle, raw DT), payload, "host supplied CRC" flag, embedded LC for B-E (voice), sync family override (SFR outbound) |
tx_end |
no more bursts: finish the queued ones (a voice call ends at the superframe boundary with its terminator, which the stack has queued), then tx_done |
tx_abort |
stop at the next slot (emergency, timeout) |
set_embedded_lc |
the LC (or talker alias / GPS embedded LC) the modem spreads over B-E from the next superframe |
set_cc_filter(cc or any) |
receive color code deframing; keeps the configured transmit color code |
is_transmitting |
slot-state based (6.1 point 5) |
set_audio_path |
vocoder PCM in / out routing and gains (where the modem owns the codec) |
power(on/off) |
chip power down / up with its init sequence |
6.4 Timing requirements on a driver
- Slot ticks every 30.000 ms +- 1.25 ms when following a signal (the chip's real-time sync correction window), with no missed tick while receiving or sending.
- Bursts set up from the driver's own interrupt for the slot after next (no stack round trip).
- RF keyed before the burst (C7000: 3.1 ms lead) and unkeyed after it (within the 2.5 ms guard time); burst length on air about 27.5-31 ms with sub-millisecond ramps.
- A
burst_rxevent for every burst heard on a slot being received, within 10 ms of its slot. tx_doneonly once the final burst (terminator, last data block) has left the antenna.- Receiving again within a few milliseconds of the last burst: a confirmed data response comes in the next frame,
30 ms after our terminator (dmr-data.md 12.9). The glue keeps a back-to-receive flag: set when the
last burst switch, or
tx_doneon a board that keeps the synthesizer on TX between bursts, put the receiver back; cleared by the next burst, a new channel and entering or leaving DMR. The core ends the transmission throughhal_radio_t.dmr_tx_end(hrc_dmr_tx_end,stm32_hrc_dmr_tx_end): while the flag is set, the board'stx_endhook ends it and leaves the receiver as it is on the same channel; otherwise the core callstx_off().rx()is always a full set-up (gotchas.md 3.14). - Recovery: a stalled modem (no tick for 200 ms) re-initialized by the driver, reported as
sync_lost.
6.5 What the stack must not assume
- That the modem tells it about late entry (it may only see voice bursts).
- That the LC buffer is fresh at the start of a call.
- That reports about received bursts are reliable while it transmits (HR_C6000: CRC, CC, sync type and header info bits are corrupt while sending).
- That the PA state means "transmitting".
- That the modem can send a CSBK or data header with a wrong CRC (C7000, C5000).
- That voice burst numbering is 0-5 or 1-6 (the driver normalizes to 0-5).
7. Gaps and uncertainties
- The HR_C7000 facts come from the chip's manual and the port. What has been seen on air is in the "Checked on each radio" records of feature-matrix.md.
- RF TX interrupt lead on the HR_C6000 has not been measured.
- Whether the C7000 has the double voice report and the stale LC behavior (assumed, as it derives from the C6000).
- ETSI hang time and wake-up retry timings are configuration in practice; the 600 ms retry is a common vendor value.
- Enhanced privacy (PI header, burst F IV) is not exercised by any of our drivers.