-
Notifications
You must be signed in to change notification settings - Fork 3
EN PCM5122 DAC
Menu path: Audio → Audio Driver → PCM5122 · Boards: ZERO2 (RP2350B) · Requires: a PCM5122 I2S DAC board (e.g. Waveshare PCM5122 Audio Board) · Build-time opt-in (see note)
⚠️ Not enabled in default builds. The PCM5122 code paths exist in the firmware, but the ZERO2 pin assignments are commented out inCMakeLists.txt, so a stock ZERO2 build does not drive the DAC. Enabling it is a custom build (uncomment thePCM5122_I2S_*/PCM5122_I2C_*defines for the ZERO2 target) — it lives on a feature branch, not onmain. The rest of this page documents how it works once built in.
The PCM5122 is a high-quality external I2S stereo DAC (TI BurrBrown, 24-bit, with on-chip headphone/line driver). On the ZERO2 (RP2350B) board you can attach one and route the emulator's mixed audio to it instead of the on-board output drivers.
Why use it over the other Audio drivers:
- PWM turns the audio into a 1-bit pulse train on a GPIO — cheap, but noisy and band-limited.
- HDMI audio embeds the sound in the HDMI data islands — only works on HDMI output, and not at all when the board is driving VGA.
- PCM5122 is a real audio DAC fed over I2S: clean line-level / headphone output with no PWM hiss, independent of the video output.
The driver talks to the chip over two buses: I2C for control/setup (reset, PLL, volume, unmute) and I2S for the audio samples. It runs the chip as an I2S slave in 3-wire mode (BCK is the master clock source, no separate SCK), 16-bit samples, at the emulator's 31.25 kHz sample rate.
Board-specific. The PCM5122 driver and its menu row are compiled in only for the ZERO2 build (
#ifdef ZERO2). On every other board the Audio Driver menu shows just Auto / PWM / i2s / AY-3-8910 / HDMI.
Two buses connect the RP2350B to the PCM5122 board:
| Signal | GPIO | Bus | Purpose |
|---|---|---|---|
PCM5122_I2C_SDA |
GPIO 2 | I2C | control data |
PCM5122_I2C_SCL |
GPIO 3 | I2C | control clock |
PCM5122_I2S_BCK |
GPIO 18 | I2S | bit clock (also the chip's master clock) |
PCM5122_I2S_LCK |
GPIO 19 | I2S | LR / word-select clock |
PCM5122_I2S_DATA |
GPIO 21 | I2S | serial audio data (DIN) |
Plus power and ground (the DAC board takes 3.3 V / 5 V per its own documentation) and the analog line/headphone output on the DAC side.
The I2C controller instance is chosen automatically from the SDA pin (even GPIO pair
→ i2c0, odd pair → i2c1); the I2C bus runs at 100 kHz with internal pull-ups
enabled. The chip answers at I2C address 0x4C.
Full GPIO map for every board: Boards & pinout.
Pin conflict — keyboard moves. On ZERO2 the I2C control pins GPIO 2 / 3 are the same pins normally used for the PS/2 keyboard (
KBD_CLOCK/KBD_DATA). A PCM5122 build relocates the keyboard to GPIO 14 / 15 so both can coexist. This is a compile-time wiring choice inCMakeLists.txt, not a runtime toggle.
Audio → Audio Driver offers (on ZERO2): Auto / PWM / i2s / AY-3-8910 / HDMI / PCM5122.
- PCM5122 — force the PCM5122 driver. On boot the firmware initialises the chip over I2C and streams audio over I2S.
- Auto — before falling back to the standard output, the firmware probes the I2C bus for a PCM5122 (a read at address 0x4C). If the chip answers, PCM5122 is used automatically; if not, it releases the pins and continues with the normal PWM/I2S detection.
Selecting a different Audio Driver applies on the next boot: you are prompted to
reboot (Apply & reboot) and the choice is saved to NVS (as audio_driver =
pcm5122).
What the I2C init sequence does (page 0 registers): software reset → set the PLL reference to BCK (3-wire, no SCK) → ignore SCK clock-error detection → wake from standby → unmute → set left/right digital volume to 0 dB.
- ZERO2 only. The driver, the pin defines and the menu entry are part of the ZERO2 build only.
- Reboot to switch. Changing the Audio Driver always requires a reboot — the choice is stored in NVS and applied at startup.
- Keyboard on GPIO 14 / 15. Because the I2C pins reuse the default PS/2 keyboard pins (GPIO 2 / 3), a PCM5122 build moves the keyboard to GPIO 14 / 15 (see above).
- ZiFi has priority on the I2S data pin. If the Network ZiFi UART is configured to use the I2S DATA pin (GPIO 21), the PCM5122 driver yields that pin and the firmware falls back to standard audio — ZiFi wins the shared pin.
- 3-wire I2S, slave mode. The chip is clocked from BCK (no separate system clock is wired), at the fixed emulator sample rate of 31.25 kHz, 16-bit stereo.
- Audio — all sound sources and the output-driver selector
- Boards & pinout — full GPIO map for ZERO2 and the other boards
- TI PCM5122 product page: https://www.ti.com/product/PCM5122
- Waveshare PCM5122 Audio Board: https://www.waveshare.com/wiki/PCM5122-Audio-Board-A
Меню (RU)
Сквозные темы
Для разработчиков