Files
DigiRadio/Software/Firmware/ADAU1701-Firmware
micheleandClaude Sonnet 5 fae2305164 Fix Si4684 pitch distortion: uncalibrated crystal (CTUN/XTAL_FREQ)
Root cause of FM/DAB "stonata" audio: xtalCtun=31/nominal XTAL_FREQ
defaults were never measured against this board's actual crystal
(Abracon ABM8-19.200MHZ-10-1-U-T, CL=10pF, two external 15pF load
caps). Fixed via CTUN trim by ear (31->0) plus a new live calibration
loop that reads the Si4684's own FM_RSQ FREQOFF field (broadcast
carriers are GPS-locked, so it's a free precision frequency reference)
to trim XTAL_FREQ with no lab equipment. Converged to CTUN=0,
XTAL_FREQ=19199750 Hz, residual -3/-4 ppm cross-checked on two
stations.

New tools/infrastructure (kept, not one-off):
- Si4684Driver::recalibrateXtal() + POST /api/tuner/xtal-calibrate:
  live crystal re-trim without an ESP32 reflash.
- FM_RSQ FREQOFF exposed as "freqoff_ppm" in GET /api/tuner/status.
- tools/si4684_xtal_calibration.py: automates the trim loop.
- tools/si4684_antenna_calibration.py: AN851 Appendix A ANTCAP/VARM/VARB
  sweep tool (same session, separate calibration).
- CONFIG_ESP32_I2S_TEST_TONE (off by default): isolates Si4684-specific
  audio issues from shared-downstream ones by writing a tone directly
  over the I2S bus the Si4684 also uses.
- SIGMA_WRITE_REGISTER_BLOCK/sigma_safeload_block now retry on NACK and
  verify via read-back instead of firing I2C writes blind.
- FM de-emphasis set to European 50us (was left at the US 75us default).
- DAB_ACF_ENABLE restored to its previous 0x0000 with a citation
  explaining why (tested the datasheet default of 0x0003, made things
  audibly worse).

See docs/si4684-rf-investigation-report.md's 2026-08-23 entry for the
full elimination chain and docs/TODO.md for follow-up work (persisting
calibration results to EEPROM instead of requiring a firmware edit).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 20:30:42 +02:00
..

ADAU1701 SigmaStudio export

SigmaStudio project DigiRadio, IC1 = ADAU1701. Shipped with DigiRadio firmware 0.8.3.

Key files

File Role
DigiRadio_IC_1.h Program/param RAM data + default_download_IC_1()
DigiRadio_IC_1_REG.h Control register map (safeload trigger)
DigiRadio_IC_1_PARAM.h Parameter cell indices (ADDR_*)
DigiRadio_NetList.xml Schematic netlist (reference)
SigmaStudioFW.h Safeload / I2C glue API

Runtime (fw 0.8.3)

  • Boot: ESP32 replays the active DspProgram over I2C via adau1701::Adau1701Driver on every power-up. Source order: valid blob in the dsp flash partition, else the embedded export from this folder (EmbeddedDspProgramSource).
  • Program update: POST /api/dsp/program with a DRAD v1 blob (see Software/tools/pack_dsp_program.py). Device reboots and loads the new script on next boot.
  • Live control: six-band PEQ, input mixer, master volume, stereo/bass enhancement overlays — safeload via audio::AudioService and REST /api/audio/*; profile persisted in encrypted NVS.
  • Web UI: Audio tab — 6 EQ sliders + mixer/enhance controls.

I2C address: 7-bit 0x34 (ADDR0=ADDR1=GND). Sample rate: 48 kHz.

Safeload implementation: components/drivers/adau1701/src/SigmaStudioFW.c. Parameter map: components/drivers/adau1701/include/adau1701/Adau1701ParamMap.hpp.

After re-exporting from SigmaStudio

  1. Action → Export System Files into this folder (overwrite headers).
  2. Reconcile new ADDR_* symbols in Adau1701ParamMap.hpp if block names moved.
  3. Rebuild and flash firmware (idf.py build).
  4. Update manual: docs/manual/ch-sigmastudio.tex, docs/manual/ch-adau1701.tex.

Do not use SigmaStudio Link Compile Download on DigiRadio — export only; the ESP32 programs the DSP at every power-up.

DRAD v1 blob (flash / HTTP upload)

Layout: magic DRAD, version u16 (=1), write count u16, CRC32 (IEEE over writes section), then for each write: address u16, length u16, data bytes. Pack from JSON with Software/tools/pack_dsp_program.py or use core::serializeDspProgramBlob() in host tests.

Documentation

  • Design: docs/manual/ch-sigmastudio.tex
  • Driver & API: docs/manual/ch-adau1701.tex
  • HTTP: docs/manual/ch-api.tex (/api/audio/*)